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

Literal types #80

Closed
2 tasks done
lars-reimann opened this issue Jun 29, 2022 · 0 comments · Fixed by #754
Closed
2 tasks done

Literal types #80

lars-reimann opened this issue Jun 29, 2022 · 0 comments · Fixed by #754
Assignees
Labels
dsl 🗒️ Issues regarding the domain specific programming language enhancement 💡 New feature or request released Included in a release

Comments

@lars-reimann
Copy link
Member

lars-reimann commented Jun 29, 2022

Is your feature request related to a problem? Please describe

For numbers, for examples, it should be possible to express that only a finite set of values is legal. This could be expressed by enum but that's quite cumbersome and you can no longer operate on enums like you could on, say, numbers.

Desired solution

Literal types: literal<"a", 1, true>

Open tasks

  • Scoping for members. Example: On something of type literal<"a", "b">, we can access any members of String. On something of type literal<"a", 1>, we can access any members of Any. On something of type literal<"a", 1, null>, we can still access any member of Any (scoping), but must use a safe access (validation).
  • Test TypeComputer.computeClassTypeForLiteralType
@lars-reimann lars-reimann added the enhancement 💡 New feature or request label Jun 29, 2022
@lars-reimann lars-reimann added the dsl 🗒️ Issues regarding the domain specific programming language label Feb 7, 2023
lars-reimann added a commit that referenced this issue Jul 11, 2023
Closes partially #80.

### Summary of Changes

* Add syntax for literal types:
  ```
  literal<1, 1.0, true, false, null, "">
  ```
* Update formatter to handle literal types

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
lars-reimann added a commit that referenced this issue Oct 21, 2023
Closes partially #80

### Summary of Changes

* Show an error if literal types have no literals
* Show an error if lists or maps are used in a literal types
* Mark literal types as experimental (show a warning when they are used)
* Compute type of manifest literal types
* Evaluate literals to a literal type instead of the corresponding
class. For example, the literal `1` now gets the type `literal<1>`
instead of `Int`).

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
lars-reimann pushed a commit that referenced this issue Oct 25, 2023
## [0.2.0](v0.1.0...v0.2.0) (2023-10-25)

### Features

* `const` modifier to replace `@Constant` annotation ([#618](#618)) ([ea4a9ba](ea4a9ba)), closes [#558](#558)
* allow instance and static members of classes to have the same name ([#583](#583)) ([1b04905](1b04905))
* automatic formatting in Langium ([#526](#526)) ([922af22](922af22)), closes [#31](#31) [#33](#33) [#513](#513) [#433](#433)
* basic implementation of partial evaluator service ([#649](#649)) ([10ed8bf](10ed8bf)), closes [#603](#603)
* built-in library ([#557](#557)) ([7998eb1](7998eb1)), closes [#433](#433)
* check `@PythonName` and `@PythonModule` ([#641](#641)) ([5a9dcbb](5a9dcbb)), closes [#543](#543)
* check context of union types ([#677](#677)) ([e846b59](e846b59)), closes [#675](#675)
* check template expressions inside `@PythonCall` ([#686](#686)) ([09bfb38](09bfb38))
* comment provider ([#688](#688)) ([e4a1b35](e4a1b35)), closes [#669](#669)
* compute types of lambdas that are passed as arguments ([#604](#604)) ([25c8707](25c8707)), closes [#541](#541)
* document symbol provider ([#659](#659)) ([fe0c8d5](fe0c8d5))
* documentation provider ([#689](#689)) ([ff70b07](ff70b07)), closes [#669](#669)
* ensure that all assignees get a value ([#630](#630)) ([e8e2bf6](e8e2bf6)), closes [#543](#543)
* error if @pythonName and @PythonCall are set on a function ([#685](#685)) ([d22c446](d22c446))
* error if argument lists are missing ([#642](#642)) ([f5ee1bd](f5ee1bd)), closes [#543](#543)
* error if class or enum are statically referenced ([#643](#643)) ([8b076e7](8b076e7)), closes [#543](#543)
* error if divisor is zero ([#644](#644)) ([9af3b81](9af3b81)), closes [#543](#543)
* error if function pointers are used ([#629](#629)) ([01933b9](01933b9)), closes [#565](#565) [#543](#543)
* error if lambda is used in wrong context ([#647](#647)) ([2d2ccc6](2d2ccc6)), closes [#409](#409) [#543](#543)
* error if left operand of type parameter constraint does not belong to declaration with constraint ([#571](#571)) ([cba3abf](cba3abf)), closes [#562](#562)
* error if member access must be null safe but isn't ([#626](#626)) ([077daff](077daff)), closes [#543](#543)
* error if names are not unique (part 2) ([#640](#640)) ([38d1181](38d1181)), closes [#543](#543)
* error if pipeline file is in a `safeds.xy` package ([#673](#673)) ([867bae3](867bae3)), closes [#671](#671)
* error if placeholder is alias for parameter or placeholder ([#628](#628)) ([b99ab25](b99ab25)), closes [#564](#564) [#543](#543)
* error if simple names of builtin declarations collide ([#678](#678)) ([275ad5e](275ad5e)), closes [#672](#672)
* error if single use annotations are used multiple times ([#631](#631)) ([17a5b7a](17a5b7a)), closes [#543](#543)
* error if type parameters don't have sufficient context ([#687](#687)) ([ea8fe29](ea8fe29))
* error if value assigned to constant parameters is not constant ([#646](#646)) ([097764d](097764d)), closes [#543](#543)
* error if wildcard import has alias ([#574](#574)) ([4ba7873](4ba7873)), closes [#543](#543)
* extensions for the `NodeMapper` ([#606](#606)) ([4fd8d86](4fd8d86))
* generation ([#634](#634)) ([c52b5e6](c52b5e6)), closes [#542](#542)
* handle backticks surrounding IDs ([#622](#622)) ([608e470](608e470)), closes [#579](#579)
* improved TextMate grammar ([#623](#623)) ([d7ff0e2](d7ff0e2))
* info if elvis operator is unnecessary ([#645](#645)) ([dcc05ce](dcc05ce)), closes [#543](#543)
* info if import alias can be removed ([#637](#637)) ([83936b8](83936b8)), closes [#636](#636)
* inlay hint provider ([#683](#683)) ([f23fa29](f23fa29)), closes [#679](#679)
* intermediate type computer ([#600](#600)) ([8d68a42](8d68a42)), closes [#541](#541)
* Langium grammar ([#470](#470)) ([c439c19](c439c19)), closes [#433](#433)
* list & map literals ([#619](#619)) ([e3b2870](e3b2870)), closes [#615](#615) [#616](#616)
* mark union types as experimental ([#676](#676)) ([4656c25](4656c25)), closes [#674](#674)
* node mapper ([#602](#602)) ([a13e5b5](a13e5b5))
* port additional checks ([#567](#567)) ([2803305](2803305)), closes [#543](#543)
* port additional validation checks to `Langium ([#576](#576)) ([8f5d57a](8f5d57a)), closes [#543](#543)
* port remaining validation infos that don't need partial evaluation ([#607](#607)) ([d53bda3](d53bda3)), closes [#543](#543)
* port validation of parameter lists ([#573](#573)) ([bd73bc5](bd73bc5)), closes [#543](#543)
* Python-like import syntax ([#598](#598)) ([4c61b8c](4c61b8c))
* PythonCall annotation ([#684](#684)) ([15114df](15114df)), closes [#617](#617)
* remove star projection and use-site variance ([#597](#597)) ([928f487](928f487))
* remove type arguments from calls ([#581](#581)) ([3e88f02](3e88f02))
* resolve references to declarations in other files ([#586](#586)) ([6b30de5](6b30de5)), closes [#540](#540)
* scoping for named types ([#563](#563)) ([a877f4c](a877f4c)), closes [#540](#540)
* scoping for own members ([#611](#611)) ([43b276f](43b276f)), closes [#540](#540)
* scoping for references to own static members ([#582](#582)) ([38afc07](38afc07)), closes [#540](#540)
* scoping for type arguments ([#585](#585)) ([3da8dd0](3da8dd0)), closes [#540](#540)
* scoping of annotation calls, type parameter constraints & yields ([#561](#561)) ([a510f2b](a510f2b)), closes [#540](#540)
* scoping of arguments ([#601](#601)) ([6b486cd](6b486cd)), closes [#540](#540)
* scoping of direct references to declarations in same file ([#580](#580)) ([491d7b0](491d7b0)), closes [#540](#540)
* semantic highlighting ([#653](#653)) ([fe8c602](fe8c602)), closes [#27](#27)
* show info if unnecessary syntax is used ([#566](#566)) ([c26d33a](c26d33a)), closes [#543](#543)
* show info that empty constraint lists can be removed ([#572](#572)) ([af13e28](af13e28)), closes [#570](#570)
* stop validation after lexing/parsing errors ([#662](#662)) ([ba1e9a8](ba1e9a8))
* syntax and formatting for literal types ([#529](#529)) ([32aca34](32aca34)), closes [#80](#80)
* syntax highlighting in documentation comments ([#690](#690)) ([83364d3](83364d3)), closes [#669](#669)
* unique names withing declarations ([#575](#575)) ([47ce782](47ce782)), closes [#543](#543)
* validate package of imports ([#627](#627)) ([18641de](18641de)), closes [#543](#543)
* validation for annotation target ([#670](#670)) ([fa7631d](fa7631d)), closes [#543](#543)
* validation for results of segments ([#613](#613)) ([bf20c7c](bf20c7c)), closes [#543](#543)
* validation for type arguments of named types ([#632](#632)) ([b72768c](b72768c)), closes [#543](#543)
* value converter for strings & ints ([#655](#655)) ([aafa2e3](aafa2e3))
* various checks for annotations on parameters and results ([#625](#625)) ([e77037e](e77037e)), closes [#543](#543)
* various checks for argument lists ([#648](#648)) ([d76e597](d76e597)), closes [#543](#543)
* various checks for calls ([#638](#638)) ([e0fa032](e0fa032)), closes [#543](#543)
* various checks related to inheritance ([#633](#633)) ([7ec746a](7ec746a)), closes [#543](#543)
* various features related to literal types ([#657](#657)) ([1775705](1775705)), closes [#80](#80)
* very basic type computer ([#596](#596)) ([b3d786c](b3d786c)), closes [#541](#541)
* warn if deprecated/experimental declarations are used ([#608](#608)) ([9b5287c](9b5287c)), closes [#543](#543) [#540](#540)
* warn if experimental language features are used ([#624](#624)) ([090fcc3](090fcc3)), closes [#108](#108)
* warn if parameters or placeholders are unused ([#612](#612)) ([3a2e9cc](3a2e9cc)), closes [#543](#543)
* warning if literal types or union types have duplicate entries ([#658](#658)) ([9ba9d20](9ba9d20))

### Bug Fixes

* CLI startup ([#560](#560)) ([4bde898](4bde898))
* duplicate error if annotation call has no argument list and lacks required parameters ([#650](#650)) ([4ba2c2c](4ba2c2c))
* mark map literals as experimental ([#656](#656)) ([ca47870](ca47870))
* resolution of references to declarations of wrong node type ([#599](#599)) ([6ae387a](6ae387a))
@lars-reimann lars-reimann self-assigned this Nov 10, 2023
lars-reimann added a commit that referenced this issue Nov 11, 2023
Closes #80

### Summary of Changes

Resolved accessed members on literals and literal types.
lars-reimann pushed a commit that referenced this issue Nov 12, 2023
## [0.3.0](v0.2.0...v0.3.0) (2023-11-12)

### Features

* annotations for the purity of functions ([#709](#709)) ([9d342e4](9d342e4)), closes [#559](#559)
* call hierarchy provider ([#735](#735)) ([168d098](168d098)), closes [#680](#680)
* compute type of elvis operators with nullable left operand ([#715](#715)) ([376b083](376b083)), closes [#541](#541)
* customize rendering of `[@param](https://github.com/param)`, `[@Result](https://github.com/result)`, and `[@type](https://github.com/type)Param` tags ([#764](#764)) ([e049148](e049148)), closes [#669](#669)
* ensure an overriding member matches the overridden one ([#758](#758)) ([a698a6a](a698a6a)), closes [#639](#639)
* error if callable type is used in wrong context ([#763](#763)) ([9b1522f](9b1522f)), closes [#713](#713)
* error if type parameter is used in nested named type declaration ([#750](#750)) ([52374aa](52374aa)), closes [#748](#748)
* info if overriding member is not needed ([#759](#759)) ([23b340e](23b340e)), closes [#25](#25)
* mark constraint lists as experimental ([#752](#752)) ([d48e1e0](d48e1e0)), closes [#18](#18)
* mark type parameter lists and type argument lists as experimental ([#755](#755)) ([f1a052a](f1a052a)), closes [#753](#753)
* mark unused internal/private segments as unnecessary ([#710](#710)) ([3ba8698](3ba8698)), closes [#682](#682)
* minor improvements for purity info ([#728](#728)) ([8d59607](8d59607))
* partially evaluate lambdas and segments ([#734](#734)) ([c40347c](c40347c)), closes [#603](#603)
* scoping for inherited members ([#706](#706)) ([4518aee](4518aee)), closes [#540](#540)
* scoping for member access on literals and literal types ([#754](#754)) ([e60e456](e60e456)), closes [#80](#80)
* scoping for references to containing declarations ([#708](#708)) ([3762c36](3762c36)), closes [#540](#540)
* show an error if a pure parameter does not have a callable type ([#736](#736)) ([6c52868](6c52868)), closes [#729](#729)
* show error if own declaration has same name as core one ([#762](#762)) ([8cb2120](8cb2120)), closes [#760](#760)
* signature help ([#724](#724)) ([ed33676](ed33676)), closes [#24](#24)
* Source Maps for Code Generation ([#714](#714)) ([64b9e07](64b9e07)), closes [#30](#30)
* tooltips for inlay hints ([#721](#721)) ([3e71cad](3e71cad))
* type checker service ([#722](#722)) ([daad5c4](daad5c4)), closes [#666](#666)
* type checking ([#723](#723)) ([a9eb3bb](a9eb3bb)), closes [#666](#666)
* type checking for list & map literals ([#751](#751)) ([dc14223](dc14223)), closes [#712](#712)
* type hierarchy provider ([#737](#737)) ([9fd5f0c](9fd5f0c)), closes [#681](#681)
* VS Code snippets ([#757](#757)) ([fd6f432](fd6f432)), closes [#756](#756)

### Bug Fixes

* assignability of static type to callable type ([#725](#725)) ([1d17900](1d17900))
* NPEs during validation ([#727](#727)) ([4b8196f](4b8196f))
* prevent overwriting core declarations ([#761](#761)) ([36663ca](36663ca))
* prevent references to following parameters from default values ([#707](#707)) ([182d64b](182d64b)), closes [#540](#540)
* setup of CLI ([#698](#698)) ([0b5d90d](0b5d90d))
@lars-reimann lars-reimann added the released Included in a release label Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dsl 🗒️ Issues regarding the domain specific programming language enhancement 💡 New feature or request released Included in a release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant