Skip to content

Conversation

@zth
Copy link
Member

@zth zth commented Nov 8, 2025

I keep hitting especially [| when doing agentic coding. A simple suggestion in the error message like the one in this PR should help the agent self-heal.

I wanted to make this as non-invasive as possible, hence where this is implemented. So I didn't want to make the parser actually understand these patterns again, just do a best-effort suggestion if it's likely that what is failing is trying to use these old patterns.

@zth zth requested review from cknitt, mediremi, nojaf and tsnobip November 8, 2025 12:25
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 8, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: bb69ce6

Copy link
Member

@mediremi mediremi left a comment

Choose a reason for hiding this comment

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

Nice work!

base
^ "\n\n\
\ The old data-last pipe `|>` has been removed from the language.\n\
\ Use a data first `->` pipe instead."
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if an LLM would understand this.
Did you test this error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it works well in my tests.

I'm not sure what to parse here when looking at "|".

The old data-last pipe `|>` has been removed from the language.
Use a data first `->` pipe instead.
Copy link
Member

Choose a reason for hiding this comment

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

Those are not interchangeable, so as a user if I natively just swap |> with ->, I'm just heading for the next error.

String.length example only works because there is one argument right?
Might be good to have an example with two or more so it becomes clear how to deal with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. I made a small wording change to call it "Refactor to use a ..." instead of "Use a ..." to signify that some form of action is needed. Given it's removed from the language, not just deprecated, I think it's enough. LLMs understand it anyway because they know what -> vs |> is. And, users who end up in this situation can continue to the next error and have something to Google for if they need more info.

@zth zth merged commit 75a5381 into master Nov 9, 2025
25 checks passed
@zth zth deleted the reason-array-syntax branch November 9, 2025 09:17
I'm not sure what to parse here when looking at "|".

The old data-last pipe `|>` has been removed from the language.
Refactor to use a data-first `->` pipe instead.
Copy link
Member

Choose a reason for hiding this comment

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

let x = "x" |> String.replace("abc", "a")
let y = "x" -> String.replace("abc","a", _)

May have also been relevant to add. Not sure if that always works though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but it's quite tricky what to suggest imo. That certainly works, but it implies continuing to use a data last API, which we don't really want to promote. But if this turns out to be an issue we can mull a bit on what example to use, if any.

Copy link
Member

Choose a reason for hiding this comment

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

That is fair though, we do want to move away from this, so that makes sense.

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.

5 participants