resem type section macros if output is not type section ast#25706
Open
metagn wants to merge 1 commit intonim-lang:develfrom
Open
resem type section macros if output is not type section ast#25706metagn wants to merge 1 commit intonim-lang:develfrom
metagn wants to merge 1 commit intonim-lang:develfrom
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type pragma macros are evaluated with
efNoSemCheckwhich means the result node of the macro is left untyped and fed back to the type section statement to be semchecked later. This is important for mutually recursive type AST to work properly.However only 1 layer of macro execution is a big limitation and makes some things impossible like optional typed args in the macro call or feeding to a typed macro as in #13830, #15334, #18864 and related issues. This is unless we wrap in
nkStmtListTypeassigned to_but this loses mutual recursion functionality.Since any output that is not
nkTypeDefornkTypeSectionis going to be rejected by the type section processor anyway, we allow these to be resemmed in case they are nodes calling into another macro that will produce a type section node. In the case that it does, the expression flag propagates and prevents semchecking for these nodes as well, allowing the type section to handle them properly. The nodes that get resemmed could be restricted to just the nodes that can produce type section AST like calls, but it is probably better to not be restrictive and makes sense just to mirror the "whitelisted" nodes in the type section processor.Since any case affected by this was directly disallowed before, this is fully backwards compatible, and enables a substantial amount of uses for type pragma macros. So maybe this could be treated as a bugfix rather than a new feature and backported. Although other issues might come up with this that would also need backporting more fixes later, but it is not likely to require a revert or break code.
I can also add this to the manual but it would require an explanation of type section semchecking mechanics which is not already there.