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

Bug: Using Dafny.dll to build an AST fails if no compiler specified. #1932

Closed
MikaelMayer opened this issue Mar 24, 2022 · 6 comments · Fixed by #1933
Closed

Bug: Using Dafny.dll to build an AST fails if no compiler specified. #1932

MikaelMayer opened this issue Mar 24, 2022 · 6 comments · Fixed by #1933
Assignees
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: parser First phase of Dafny's pipeline

Comments

@MikaelMayer
Copy link
Member

Since #1894 , ModuleExportDecl.FullCompileName used in the constructor of ModuleExportDecl can throw a null pointer exception because TopLevelDecl.FullCompileName now depends on DafnyOptions.O.Compiler, which does not have a default value.

@MikaelMayer MikaelMayer added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: parser First phase of Dafny's pipeline labels Mar 24, 2022
@MikaelMayer MikaelMayer self-assigned this Mar 24, 2022
MikaelMayer added a commit that referenced this issue Mar 24, 2022
@cpitclaudel
Copy link
Member

Can you give a repro for this issue? The option-parsing code does Compiler ??= new CsharpCompiler();; when is it not called?

@cpitclaudel
Copy link
Member

In other words, it's intended that FullCompileName depends on the compiler; the bug is that Compiler is null, and that's what we should fix.

@MikaelMayer
Copy link
Member Author

The method ApplyDefaultOptions() is never called if one builds a DafnyOptions using the constructor.
Previously, it was only depending on whether the compiler target was C# or not, not the full compiler.

@cpitclaudel
Copy link
Member

Previously, it was only depending on whether the compiler target was C# or not, not the full compiler.

Initializing a compiler instance doesn't really do that much, so it would be fine to initialize the compiler to be the C# one. But isn't it good that you get an error? It tells you that your code may depend on the internals of the compiler, which is good to know?

@keyboardDrummer
Copy link
Member

keyboardDrummer commented Mar 30, 2022

When this does bug occur? It seems like it occurs if DafnyOptions.O are not properly initialised, like you might forget to do in a test. Isn't initialising them properly the fix then?

@MikaelMayer
Copy link
Member Author

Yes indeed. However, previously, parsing would succeed even though DafnyOptions.O is not properly initialized. Users setting themselves the options without depending on our custom initialization faced the problem of having a field that is uninitialized (Compiler), which break their code.

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 part: parser First phase of Dafny's pipeline
Projects
None yet
3 participants