Skip to content

Simple arrays swap fails, when inlined #8058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edolgy opened this issue Jan 21, 2020 · 0 comments
Closed

Simple arrays swap fails, when inlined #8058

edolgy opened this issue Jan 21, 2020 · 0 comments

Comments

@edolgy
Copy link

edolgy commented Jan 21, 2020

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

odersky added a commit to dotty-staging/dotty that referenced this issue Jan 22, 2020
Before the fix to scala#8058, a reference `x` with constant type `0` was
deemed to have a stable member symbol since its symbol did not exist.
That's what gave the reference the `PurePath` status. Now that
`isStableMember` is fixed, this needs to be asserted
explicitly.
smarter added a commit that referenced this issue Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant