eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
728 stars 65 forks source link

Praser shows error after upgrading to 1.1.0 #938

Closed jiashengguo closed 1 year ago

jiashengguo commented 1 year ago

Langium version: 1.1.0 Package name: langium

Steps To Reproduce

  1. git clone https://github.com/jiashengguo/my-blog-app.git
  2. npm install
  3. npm exec zenstack generate

The current behavior

An unexpected error occurred: Error: Could not find name assignment for type: TypeDeclaration at buildCrossReference (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:236:19) at buildElement (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:47:18) at buildElement (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:44:18) at buildAlternatives (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:136:22) at buildElement (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:53:18) at /Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:219:45 at Array.map () at buildGroup (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:219:36) at buildElement (/Users/jiasheng/branch/bug/node_modules/langium/lib/parser/parser-builder-base.js:59:18)

The expected behavior:

No error

Description

The command is to parse the schema.zmodel file in the project using the below grammar file https://github.com/zenstackhq/zenstack/blob/main/packages/language/src/zmodel.langium

if you downgrade the Langium to 1.0.1, then it works. Is there any grammar-breaking change for 1.1.0?

msujew commented 1 year ago

Oh, that's not good. The issue is very likely due to https://github.com/langium/langium/pull/845 and an unintended breakage in the grammar. In theory the breakage is only internal (i.e. no externally facing API has changed), but in practice it will require users to regenerate their grammar to fit with the new grammar structure. That's my bad, sorry. I've just created https://github.com/langium/langium/pull/939 to make users aware of this issue.

We actually changed our generated package.json for a similar reason. We recommend users of Langium to use the ~ package resolution to prevent breakages accidentally sneaking into their package. The issue is that Langium's large API surface makes it impossible to change anything without breaking some code.