Actions can rewrite declared types
See original GitHub issueActions 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)
Instead:
- 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:
- Created a year ago
- Comments:5 (5 by maintainers)
Top 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 >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
@montymxb
I would like to propose: A is a declared type and cannot be redefined
(Note: Code actions are an LSP request type, which is totally unrelated to actions in the grammar)