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

Ordering problem in Python code generator #5569

Open
RustanLeino opened this issue Jun 24, 2024 · 0 comments
Open

Ordering problem in Python code generator #5569

RustanLeino opened this issue Jun 24, 2024 · 0 comments
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label lang: python Dafny's Python transpiler and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag

Comments

@RustanLeino
Copy link
Collaborator

Dafny version

4.6.0

Code to produce this issue

method Main() {}

class C extends Trait {}
trait Trait {}

Command to run and resulting output

% dafny run test.dfy --target=py

Dafny program verifier finished with 0 verified, 0 errors
Traceback (most recent call last):
  File "./test-py/__main__.py", line 7, in <module>
    import module_
  File "./test-py/module_.py", line 22, in <module>
    class C(Trait):
            ^^^^^
NameError: name 'Trait' is not defined

What happened?

The two type declarations in the Dafny program are generated into Python declarations in the same order. Evidently, Python does not like that order.

By declaring Trait before C in the Dafny program, the Python declarations also get swapped, so then the Python is well-formed.

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

Mac

@RustanLeino RustanLeino added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag lang: python Dafny's Python transpiler and its runtime labels Jun 24, 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 part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag
Projects
None yet
Development

No branches or pull requests

1 participant