Alternative including cross reference and string is recognized as reference to string
See original GitHub issueAn alternative including a cross reference to X
and strings sometimes can be recognized as a reference to X | string
A minimal example is as follows.
grammar Debug
entry Model: (items+=(A | B))*;
interface B {
b: @A | string;
}
A infers A: 'A' a=ID;
B returns B: 'B' b=([A:ID] | 'C');
hidden terminal WS: /\s+/;
terminal ID: /[_a-zA-Z][\w_]*/;
Langium-vscode gives a diagnostic.
The assigned type 'Reference<'C' | A>' is not compatible with the declared property 'b' of type 'Reference<A> | string'.
''C' | A' is not expected.
The type of [A:ID]|'C'
is recognized as Reference<'C'|A>
instead of Reference<A>|'C'
.
Adding an action to the rule B
resolves this error: B returns B: {B} 'B' b=([A:ID] | 'C');
.
If the rule B
is written using infers
instead of returns
, there is no diagnostic, but in the generated ast, type of b
is still incorrect. Also, adding an action in such case does not resolve the error.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Python cross-reference type definitions [duplicate]
You can use forward references by using the type name as a string: python.org/dev/peps/pep-0484/#forward-references.
Read more >Manipulating a \ref{} as a string - TeX - LaTeX Stack Exchange
I want to use macros from xstring to operate on the string produced by a \ref{} . Specifically I have a macro that...
Read more >Item Cross References | Sage Intacct Developer
ID of the inventory item that will have the cross reference. ALTERNATEITEMID, Optional, string, ID of an alternate item. Required when using an...
Read more >Cross reference - Alternate type - Acumatica Community
Can we rename the Alternate Typee.g “Global” I want to rename to “ABC”
Read more >THE BLUEBOOK MADE EASY - Penn State Law
This Guide will cover only the most general Bluebook rules; Most of the slides will first reference in italics the table, rule, or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@msujew Would give a nice error message:
Mixing references and other types might break quite a few things in Langium.
xDI like the error message 👍