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

[Python] Incorrect reserved word escaping for dependency modules #5469

Closed
lucasmcdonald3 opened this issue May 20, 2024 · 0 comments · Fixed by #5476
Closed

[Python] Incorrect reserved word escaping for dependency modules #5469

lucasmcdonald3 opened this issue May 20, 2024 · 0 comments · Fixed by #5476
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: python Dafny's Python transpiler and its runtime

Comments

@lucasmcdonald3
Copy link
Contributor

Dafny version

4.6.0

Code to produce this issue

./SomeDependencyModule.dfy:

module SomeDependencyModule {
    datatype None = | None (
    )

    const test := None()
}

---

./SomeModule.dfy:

include "SomeDependencyModule.dfy"

module SomeModule {

  import SomeDependencyModule

  const test := SomeDependencyModule.None()

}

Command to run and resulting output

Compile:

dafny translate py SomeDependencyModule.dfy
dafny translate py SomeModule.dfy

Run:

lucmcdon@80a997335f93 none % cd SomeModule-py 
lucmcdon@80a997335f93 SomeModule-py % python3 
Python 3.12.3 (main, May  9 2024, 13:24:59) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import SomeModule
>>> SomeModule.default__.test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lucmcdon/.pyenv/versions/3.12.3/lib/python3.12/site-packages/_dafny/__init__.py", line 15, in __get__
    return classmethod(self.fget).__get__(None, owner)()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lucmcdon/workplace/dafny_test/none/SomeModule-py/SomeModule.py", line 19, in test
    return SomeDependencyModule.None__None()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'SomeDependencyModule' has no attribute 'None__None'. Did you mean: 'None_None'?

What happened?

SomeDependencyModule.py correctly references the generated None_None type.
SomeModule.py incorrectly references the generated None_None type by referring to it as None__None.
I expected SomeModule to reference it as None_None.

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

Mac

@lucasmcdonald3 lucasmcdonald3 added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label May 20, 2024
@fabiomadge fabiomadge added the lang: python Dafny's Python transpiler and its runtime label May 21, 2024
fabiomadge added a commit to fabiomadge/dafny that referenced this issue May 21, 2024
fabiomadge added a commit that referenced this issue May 22, 2024
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 lang: python Dafny's Python transpiler and its runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants