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

Compilation Error: generates duplicate local variable declarations #15

Closed
laurejt opened this issue Jul 26, 2016 · 0 comments
Closed

Compilation Error: generates duplicate local variable declarations #15

laurejt opened this issue Jul 26, 2016 · 0 comments
Assignees

Comments

@laurejt
Copy link

laurejt commented Jul 26, 2016

Dafny verifies the following program, but generates invalid code.

datatype bar = Bar
datatype obj = Obj(fooBar:map<foo,bar>)
datatype foo = Foo

method test_case() returns (o:obj)
{
    if true {
        o:= o.(fooBar := o.fooBar[Foo := Bar]);
    }
}

The compilation error generated is:

error CS0136: A local variable named '_pat_let_tv1' cannot be declared in this scope because it would give a different meaning to '_pat_let_tv1', which is already used in a 'parent or current' scope to denote something else

The segment of the generated code causing this error is:

public static void @test__case(out @obj @o)
  {
    @o = new @obj();
  TAIL_CALL_START: ;
    var @_pat_let_tv1= @o;
    if (true)
    {
      var @_pat_let_tv1= @o;
      @o = Dafny.Helpers.Let<@obj,@obj>(@o, _pat_let0_0 => Dafny.Helpers.Let<@obj,@obj>(_pat_let0_0, @_2_dt__update__tmp_h0 => new @obj(new obj_Obj(((@_pat_let_tv1).@dtor_fooBar).Update(new @foo(new foo_Foo()), new @bar(new bar_Bar()))))));
    }
  }

If the if statement is removed, code generation is correct.

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

No branches or pull requests

1 participant