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

Miscompile when attempting to |> throw #1513

Closed
bbrk24 opened this issue Oct 26, 2024 · 3 comments · Fixed by #1517
Closed

Miscompile when attempting to |> throw #1513

bbrk24 opened this issue Oct 26, 2024 · 3 comments · Fixed by #1517
Labels
proposal Proposal or discussion about a significant language feature

Comments

@bbrk24
Copy link
Contributor

bbrk24 commented Oct 26, 2024

What the heck is going on here

try
    ;
catch err
    if err <? RangeError
        new StackTracingError
            `${err.message}`
            cause: err
        ||> .addCall raw
        |> throw
    throw err
(() => {
  throw (() => {
    throw err;
  })();
})()(
  (() => {
    try {
    } catch (err) {
      let ref;
      return err instanceof RangeError
        ? ((ref = new StackTracingError(`${err.message}`, {
            cause: err,
          })).addCall(raw),
          ref)
        : void 0;
    }
  })(),
);
@bbrk24
Copy link
Contributor Author

bbrk24 commented Oct 26, 2024

Oh, I see what's happened. Simple |> throw isn't supported, so it instead parses as this:

(
    try
        ;
    catch err
        if err <? RangeError
            new StackTracingError
                `${err.message}`
                cause: err
            ||> .addCall raw
) |> throw throw err

@edemaine
Copy link
Collaborator

|> throw sounds like a useful and simple addition (similar to |> return, |> await, etc.). Do you want to work on it?

@bbrk24
Copy link
Contributor Author

bbrk24 commented Oct 26, 2024

I can certainly take a look at it later today.

@edemaine edemaine added the proposal Proposal or discussion about a significant language feature label Oct 26, 2024
@bbrk24 bbrk24 mentioned this issue Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal or discussion about a significant language feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants