Skip to content
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

Wrong imperative translation when mutable object returned (AntiAliasing, effects) #947

Closed
vkuncak opened this issue Mar 24, 2021 · 2 comments

Comments

@vkuncak
Copy link
Collaborator

vkuncak commented Mar 24, 2021

This verifies on master as of today:

object Test {
  case class IntRef(var x:Int)
  def f = IntRef(42)

  def g(d1: IntRef, d2: IntRef) = {
    val x1 = d1.x
    d2.x = 33
    assert(d1.x==x1)
  }
  
  def mytest:Unit = {
    val c1 = f
    val c2 = c1
    g(c1, c2)
  }
}

Running Test.mytest in scala REPL crashes in assertion, as I would expect.

@vkuncak
Copy link
Collaborator Author

vkuncak commented Mar 24, 2021

"The aliasing check in function invocation arguments is pretty useless...

args.find { case v: Variable => vis.contains(v) case _ => false }

aliasing can occur with fields, e.g. a.b and a.b are aliased which won't be caught by the check
We can probably do something like finding conservative targets using Try(getTargets(e)).toOption.getOrElse(variablesOf(e))
"

@jad-hamza
Copy link
Contributor

Fixed by PR #965

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

2 participants