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.

Actions can rewrite declared types

See original GitHub issue

Actions can rewrite declared types, effectively erasing/changing their previously declared properties. This leads to an inability to reason about declared types as a fixed source of information about the resulting AST that is generated.

An example grammar in Langium that causes this:

// 1. define some interface
interface A {
    val: string

// X inherits correctly from A via a code action, leaving A unchanged
X: 'x' {A} val=ID;

// but Y redefines A entirely
Y: 'y' {infer A} q='broken';

assumes the ID terminal is declared

This generates the following interface, which is not correct:

export interface A extends AstNode {
    q: 'broken'

Langium version: 0.3.0 (dev)


  • declared types should be immutable, their properties should not be open to changing, erasure, or addition.
  • validation should indicate something like A is a declared type and cannot be inferred
  • optional: add a code action to rewrite {infer A} to {A} (could potentially be in a separate PR)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

dhuebnercommented, May 30, 2022


A is a declared type and cannot be inferred

I would like to propose: A is a declared type and cannot be redefined

spoenemanncommented, May 30, 2022

(Note: Code actions are an LSP request type, which is totally unrelated to actions in the grammar)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generated declaration files rewrite import paths #42155 - GitHub
Generated declaration file imports types via relative path ( "../../styles/src" ). This path is invalid once published to npm. I was under the ......
Read more >
Examples of my most useful IIS rewrite rules - Yaplex
Your rewriteRules.config file will look like below, it does not need the schema declaration and starts directly from <rules> tag.
Read more >
mod_rewrite - Apache HTTP Server Version 2.4
The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, ......
Read more >
Table-driven Declarative Rewrite Rule (DRR) - MLIR - LLVM
The declarative rewrite rule is operation-based: it describes a rule to match against a directed acyclic graph (DAG) of operations and generate DAGs...
Read more >
714-Amendments, Applicant's Action - USPTO
Amendments to a claim must be made by rewriting the entire claim with all changes ... The type of amendment will determine whether...
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