Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The strict mode for types inference #385

Open
pluralia opened this issue Jan 20, 2022 · 2 comments
Open

The strict mode for types inference #385

pluralia opened this issue Jan 20, 2022 · 2 comments
Labels
good first issue Good for newcomers types Types related issue

Comments

@pluralia
Copy link
Contributor

pluralia commented Jan 20, 2022

In Langium 0.2.0 types are inferred from rules names implicitly. For example, the following 2 examples will infer a type MyRule with the attribute name.

MyRule:
    name=ID;
MyRule returns MyRule:
    name=ID;

When we add types, type inference like described above will still be allowed by default.

This feature issue proposes to add the strict mode, when implicit type inference is forbidden. So, the way to specify a type of MyRule in the strict mode is:

type MyRule = {
    name: string
}

MyRule returns MyRule:
    name=ID;
@pluralia pluralia added the types Types related issue label Jan 20, 2022
@pluralia pluralia added this to the v0.4.0 milestone Jan 20, 2022
@pluralia
Copy link
Contributor Author

We can generate "a type system template" automatically in the strict mode. So, we just infer types like in the "default" mode and put them in separate .langium file. As the result:

  1. The strict mode works out of box
  2. A user develops the type system by adding and modifying types instead of creating everything from zero

@danieldietrich proposed to add that functionality to the CLI.

@spoenemann
Copy link
Contributor

This will be considerably easier to implement with #438 and #440.

@spoenemann spoenemann modified the milestones: v0.4.0, v0.5.0 May 13, 2022
@spoenemann spoenemann removed this from the v0.5.0 milestone Sep 14, 2022
@pluralia pluralia added the good first issue Good for newcomers label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers types Types related issue
Projects
None yet
Development

No branches or pull requests

4 participants