Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alternative including cross reference and string is recognized as reference to string

See original GitHub issue

An 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:closed
  • Created a year ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

dhuebnercommented, Dec 12, 2022

@msujew Would give a nice error message: Mixing references and other types might break quite a few things in Langium. xD

luan-xiaokuncommented, Dec 14, 2022

I like the error message 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python cross-reference type definitions [duplicate]
You can use forward references by using the type name as a string:
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 >
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found