Skip to content

Conversation

cknitt
Copy link
Member

@cknitt cknitt commented Sep 13, 2025

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.

@cknitt cknitt marked this pull request as draft September 13, 2025 06:56
@@ -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 [])
Copy link
Member Author

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?

Copy link
Member

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".
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or here

Copy link

pkg-pr-new bot commented Sep 13, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7887

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7887

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7887

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7887

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7887

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7887

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7887

commit: 7866081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants