question-mark
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.

Incorrect properties lifting to the parent node

See original GitHub issue

Rules AssignmentExpression, OrExpression and AndExpression have a common property operator and inherit BinaryExpression, so the BinaryExpression in the generated AST interface has to contain a property operator: 'Or' | 'And' | ':'. However, type of the operator is 'Or' | 'And', because it omits an operator of the AssignmentExpression rule.

entry Model:
    elements+=OrAndAssignmentExpression*;

OrAndAssignmentExpression infers Expression:
    OrExpression ({infer AssignmentExpression.left=current} operator=':' right=OrExpression)*;

// Dummy rule to make AssignmentExpression inherit from BinaryExpression
AssignmentExpression infers BinaryExpression:
    {infer AssignmentExpression} left=ID operator=':' right=OrExpression;

OrExpression infers Expression:
	AndExpression ({infer BinaryExpression.left=current} operator='Or' right=AndExpression)*;

AndExpression infers Expression:
	ValueExpression ({infer BinaryExpression.left=current} operator='And' right=ValueExpression)*;

ValueExpression infers Expression:
	{infer BoolValue} value=BOOL | {infer IDValue} value=ID;

terminal ID:				   /\$?[_a-zA-Z][\w_]*/;
terminal BOOL returns boolean: /(true)|(false)/;

Langium version: 0.5.0 Package name: langium-cli

Steps To Reproduce

  1. Generate an AST with the grammar above
  2. Check out the BinaryExpression rule in the AST

The current behavior

Type of operator from BinaryExpression doesn’t contain ':'.

export interface BinaryExpression extends Expression {
    operator: 'Or' | 'And'
    ...
}

The expected behavior

Type of operator from BinaryExpression contain ':'.

export interface BinaryExpression extends Expression {
    operator: 'Or' | 'And' | ':'
    ...
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
montymxbcommented, May 23, 2022

I’ll jump on this one :octocat:

0reactions
montymxbcommented, May 30, 2022

There’s also a problem w/ formal reasoning about what makes a rule valid, until 510 is added. Currently we can’t assume that a rule returning some type (inferred or declared) will be valid if it satisfies the properties stated by the type, because we can’t validate the inheritance that is used to build that type. Normally we could duplicate the property in the child type to fix this, but that’s disallowed, and puts us in a bit of a quandary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Checked property of a parent node is incorrectly updated ...
Hi issue still present. It is fixed partial case on moment when node being hidden. When you add node after hiding some node...
Read more >
Slot content has incorrect parentNode value #658 - GitHub
We found this issue with slots by comparing with native Shadow DOM. shadow -> slot -> assigned nodes -> div -> parent =...
Read more >
Editing and organising nodes - NVivo 12 for Windows
In List View, select the Node to be renamed. Right click and select Node Properties. Enter desired changes to the name and click...
Read more >
SKSpriteNode gets hidden below parent node - Stack Overflow
Using Swift and SpriteKit, I have a problem with SKSpriteNode not showing when being added as a child to another SKSpriteNode. In contrast,...
Read more >
parentNode Property1 | Microsoft Learn
The property is read-only. All nodes except Document, DocumentFragment, and Attribute nodes can have a parent. However, if a node has just ...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found