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

Opaque functions passed as arguments causes type checking errors #4202

Closed
EkanshdeepGupta opened this issue Jun 20, 2023 · 1 comment · Fixed by #4203
Closed

Opaque functions passed as arguments causes type checking errors #4202

EkanshdeepGupta opened this issue Jun 20, 2023 · 1 comment · Fixed by #4203
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label

Comments

@EkanshdeepGupta
Copy link
Collaborator

Dafny version

4.1.0

Code to produce this issue

opaque function F(x: int): char
{ 'D' }

method InitArray<D>(f: int -> D) returns (a: D)
{
  return f(44);
}

method Main() {
  reveal F();
  var c := InitArray(F);
}

Command to run and resulting output

$ dafny verify ../../Test/test.dfy
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/Users/ekanshdg/Test/test.dfy(44,16): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/Users/ekanshdg/Test/test.dfy(54,21): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
7 type checking errors detected in /var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl

*** Encountered internal translation error - re-running Boogie to get better debug information

/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4580,4): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4581,2): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4582,8): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4589,13): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4602,4): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4603,2): Error: wrong number of arguments to function: _module.__default.F (2 instead of 3)
/var/folders/v7/dtr5626966sf_f5665tczxpw0000gr/T/test__module.bpl(4641,12): Error: wrong number of arguments to function: _module.__default.F#Handle (2 instead of 1)

What happened?

Because opaque functions generate an extra argument, that is causing type-checking to fail when an opaque function is passed as an argument.

What type of operating system are you experiencing the problem on?

Mac

@EkanshdeepGupta EkanshdeepGupta added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Jun 20, 2023
MikaelMayer added a commit that referenced this issue Jun 20, 2023
@stefan-aws
Copy link
Collaborator

See also #3504

MikaelMayer added a commit that referenced this issue Jun 22, 2023
This PR fixes #4202
I added the corresponding test.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants