-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow local modules to be forward referenced (#3275)
This pr makes a number of changes to the Scoper. The most important change is that local modules can be forward referenced. Below I list all the changes. - Closes #3032 # Referencing local modules Local modules can now be forward referenced. However, there is one restriction: 1. When forward referencing a local module. The symbols that come from an `open public` are **not** yet in scope, so they can't be referenced. E.g. ``` -- at this point, P.p is in scope, but P.m is not module P; axiom p : Type; open M public; end; -- at this point, both P.p and P.m are in scope module M; axiom m : Type; end; ``` # Forward reference passed an import, open or module statement The following example was not allowed but now it is. ``` axiom A : B; import M; module S; end; axiom B : Type; ``` # Changes in operators and iteratos The semantics of operator and iterator definitions have changed slightly. Before, when the scoper found `syntax operator , pair`, it would remember in the state that when the `,` symbol is defined in the current syntax block, it should have the fixity `pair`. These had some implications. 1. It was not possible to reassign/overwrite a fixity. 1. The `,` symbol in the `syntax operator , pair` is not highlighted and it doesn't support going to definition. 2. We required special checks to throw an error when we had duplicate operator/iterator definitions. We also had a check for when a symbol used in an operator/iterator statement was not defined in the same syntax block. The new behaviour is as follows. 1. When the scoper finds `syntax operator , pair`, the symbol `,` is scoped using the regular scoping rules - so `,` must be in scope. Then, the scoper modifies the fixity for `,` in the current scope. 2. It is now possible to overwrite the fixity of a symbol. So this would be possible. ``` syntax operator , pair; p1 : Pair Nat Nat := 1, 2; syntax operator , none; p2 : Pair Nat Nat := , 1 2; ``` 6. It is now possible to have qualified names in syntax/iterator definitions. E.g. `syntax operator Pair., pair`. Because of point 1) we might encounter some breaking changes. 1. ``` syntax operator mkpair none; syntax alias mkpair := ,; ``` This is now invalid because `mkpair` is not in scope in the `syntax operator` statement, because aliases cannot be forward referenced. 2. A `syntax operator op fix` will now throw an ambiguity error if `op` is both defined in this module and imported from somewhere else. # Qualified fixities It is now possible to reference fixities using qualified names. E.g. ``` syntax operator , Fixities.pair; ``` # Pending tasks - [x] Add positive test for local module forward referencing. - [x] Add positive test for fixity overwriting. - [x] Add positive test for qualified fixity. - [x] Add positive test for qualified operator. - [x] Add negative tests for local module forward referencing restrictions. - [x] Fix printing of operators in Core. - [x] Cleanup the code.
- Loading branch information
1 parent
b1b3951
commit 62ce181
Showing
42 changed files
with
1,273 additions
and
1,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule juvix-stdlib
updated
3 files
+2 −2 | Stdlib/Data/Field/Base.juvix | |
+1 −1 | Stdlib/Data/Map.juvix | |
+1 −1 | Stdlib/Data/Set.juvix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.