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

linear type-checking doesn't handle simultaneity right #29

Open
tjhance opened this issue May 18, 2021 · 2 comments
Open

linear type-checking doesn't handle simultaneity right #29

tjhance opened this issue May 18, 2021 · 2 comments
Labels
good first issue Good for newcomers

Comments

@tjhance
Copy link
Collaborator

tjhance commented May 18, 2021

Right now, Dafny lets this pass:

linear datatype Foo = Foo 

method f(linear x: Foo)
returns (linear x': Foo)
{
  x' := x;
  linear var y: Foo;

  y, x' := x', y;
}

but not this:

method g(linear x: Foo, linear y: Foo)
returns (linear x': Foo, linear y': Foo)
{
  x' := x;
  y' := y;

  x', y' := y', x'; 
}

It should be the other way around.

@tjhance tjhance added bug Something isn't working good first issue Good for newcomers labels May 18, 2021
@Chris-Hawblitzel
Copy link
Collaborator

Due to the way Dafny resolves multi-assignment, I just disabled multiple-right-hand-side assignment to linear variables for soundness's sake. Multiple assignment from method calls still works, so you can do:

method Assign2<A, B>(linear a: A, linear b: B) returns(linear a': A, linear b': B)
  ensures a' == a;
  ensures b' == b;
{
  a' := a;
  b' := b;
}

method f(linear x: int, linear y: int) returns (linear x': int, linear y': int)
{
  x' := x;
  y' := y;

  x', y' := Assign2(y', x'); 
}

@tjhance tjhance removed the bug Something isn't working label May 19, 2021
@tjhance
Copy link
Collaborator Author

tjhance commented May 19, 2021

ok cool. I'll leave this issue up as a note that it would still be great to support the latter example at some point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants