Skip to content

Simple arrays swap fails, when inlined #8058

Closed
@edolgy

Description

@edolgy
given (x: Array[Char]) extended with {
  inline def swap(i: Int, j: Int) : Unit =
    val v = x(i)
    x(i)  = x(j)
    x(j)  = v
}

val a = Array('A','B')

a.swap(0,1)

println(a.toList)

// Run Result
List(B, B)

// Expectation
List(B, A)

If "inline" is removed, the expectation is fulfilled

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions