-
Notifications
You must be signed in to change notification settings - Fork 38
Feature: relax the constraint of ...
in list construction
#670
Comments
This issue seems raised from here. Line 3727 in c2b5750
The current behavior is: if the last list element expression is a spread, the parser will not check the rest element whether contains a spread expression. So the list expression list{...a, ...b ,...a} would be parsed to OCaml a :: b :: a which raises a type error in subsequent type checking. But list{...a, ...b, c} would raise a syntax error, because the last is not a spread. My commit seems fix this. Would someone help review my code? |
Would you create a pull request? |
* fix issue (#670) * formatting issue * rename to improve readability * comment on the boolean value indicates spread expr * formatting issue * fix syntax error in error message * update CHANGELOG.md * tweak Co-authored-by: zdh <[email protected]> Co-authored-by: Cristiano Calcagno <[email protected]>
@butterunderflow when multiple
==> This would make a working version first, we could improve the performance later |
As far as I understand, after this feature is added, there will be no syntax errors related to wrong spread location, since spread expression at anywhere could be compiled to list concatenation. Do I understand correctly? |
yes |
Currently,
...
is only allowed in the tail position,list {1,2,... tail}
,For example:
The current situation is a bit weird, it is not a syntax error, but a type error
This has type: int Somewhere wanted: list<int>
This also seems to be a bug:
The inferred type for
b
isint
The text was updated successfully, but these errors were encountered: