-
Notifications
You must be signed in to change notification settings - Fork 261
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
feat!: New behavior for opened import where module contains homonymous top-level declaration #2355
Merged
Commits on Jul 1, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 444df54 - Browse repository at this point
Copy the full SHA 444df54View commit details -
Configuration menu - View commit details
-
Copy full SHA for 415f97e - Browse repository at this point
Copy the full SHA 415f97eView commit details -
feat!: Let M refer to M.M in opened import
For `import opened M` where `M` is a module that declares a top-level `M`, let `M` in the importer refer to that top-level `M` instead of referring to the module `M`. Fixes dafny-lang#1996
Configuration menu - View commit details
-
Copy full SHA for aedc64e - Browse repository at this point
Copy the full SHA aedc64eView commit details -
Configuration menu - View commit details
-
Copy full SHA for bf0eddd - Browse repository at this point
Copy the full SHA bf0edddView commit details
Commits on Sep 13, 2022
-
Merge branch 'master' into issue-1996
# Conflicts: # RELEASE_NOTES.md
Configuration menu - View commit details
-
Copy full SHA for bef8d31 - Browse repository at this point
Copy the full SHA bef8d31View commit details -
Configuration menu - View commit details
-
Copy full SHA for 894acaf - Browse repository at this point
Copy the full SHA 894acafView commit details
Commits on Sep 15, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 397884f - Browse repository at this point
Copy the full SHA 397884fView commit details
Commits on Sep 16, 2022
-
Raise resolution errors instead of silently changing behavior
The resolution change introduced by the previous commit silently changes the meaning of existing Dafny programs. This commit does its best to detect these cases and raise resolution errors instead. To illustrate the technique, consider the following example: module Option { static const a := 1 datatype Option = … { static const a := 2 } } module X { import opened Option method M() { print Option.A; } } This program printed 1 in previous versions of Dafny. It would print 2 with the new resolution strategy introduced in this commit. To avoid that, the program is rejected instead. To do so, we keep track of shadowing in a separate table: * Source/DafnyCore/AST/TopLevelDeclarations.cs (ModuleSignature): Add a new field `ShadowedImportedModules`. * Source/DafnyCore/Resolver.cs (ResolveOpenedImports): Keep track of shadowed modules. This table is used in `ResolveDotSuffix`: * Source/DafnyCore/Resolver.cs (ResolveNameSegment): Return name of shadowed module, if any, as an out parameter (ResolveDotSuffix): Before returning, make sure that the same name could not have been resolved in the parent module. The check is performed in `CheckForAmbiguityInShadowedImportedModule`, which runs a simplified version of resolution of a name in a module: * Source/DafnyCore/Resolver.cs (CheckForAmbiguityInShadowedImportedModule): Error out if the shadowed module contains a conflicting name (a name that would previously would have been instead of the one that the new resolution algorithm picks). (NameConflictsWithModuleContents): Determine whether a conflicting name exists. The check is an over-approximation: it disallows certain cases in which the old program would not have compiled due to ambiguity, for example. Two subtle additional difficulties: - Constructors are visible in a datatype and in its parent module. This means that without special care we would disallow expressions like `Option.Some`. - Code that was previously ambiguous now compiles unambiguously. One specific example is datatype constructors: previously, if two datatypes in a module defined same-named constructors, references to `Module.Constructor` were ambiguous. Now, if one of the datatype has the same name as the module, then such references are legal and unambiguously resolve to the constructors of that datatype.
Configuration menu - View commit details
-
Copy full SHA for 33ee242 - Browse repository at this point
Copy the full SHA 33ee242View commit details -
Configuration menu - View commit details
-
Copy full SHA for f3427f6 - Browse repository at this point
Copy the full SHA f3427f6View commit details
Commits on Sep 19, 2022
-
Configuration menu - View commit details
-
Copy full SHA for a8eccfb - Browse repository at this point
Copy the full SHA a8eccfbView commit details
Commits on Sep 20, 2022
-
Configuration menu - View commit details
-
Copy full SHA for dfaf7fd - Browse repository at this point
Copy the full SHA dfaf7fdView commit details
Commits on Sep 21, 2022
-
Merge branch 'master' into issue-1996
# Conflicts: # RELEASE_NOTES.md
Configuration menu - View commit details
-
Copy full SHA for 55f19a9 - Browse repository at this point
Copy the full SHA 55f19a9View commit details -
Configuration menu - View commit details
-
Copy full SHA for cfdffb4 - Browse repository at this point
Copy the full SHA cfdffb4View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.