-
Notifications
You must be signed in to change notification settings - Fork 471
Very basic implementation of for..of loops #7887
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
base: master
Are you sure you want to change the base?
Conversation
@@ -450,6 +450,9 @@ module E = struct | |||
| Pexp_for (p, e1, e2, d, e3) -> | |||
for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d | |||
(sub.expr sub e3) | |||
| Pexp_for_of (_pat, _array_expr, _body_expr) -> | |||
(* Convert for...of to an extension since it doesn't exist in old AST *) | |||
extension ~loc ~attrs (Location.mkloc "rescript.for_of" loc, PStr []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what needs to be done here.
How can we map to ast0 in such a way that we can map it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extension sounds reasonable.
|
||
1 │ for x | ||
2 │ | ||
|
||
Did you forget a `in` here? | ||
I'm not sure what to parse here when looking at "eof". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what to do about this change in the test output here
5 │ Js.log("for") | ||
6 │ } | ||
|
||
consecutive statements on a line must be separated by ';' or a newline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or here
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
My assistant and I created a very basic implementation of for...of loops that only works on arrays for now.
Will need to think about how to support iterators later.