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

Add SyntaxError#path #3433

Merged
1 commit merged into from
Mar 19, 2024
Merged

Add SyntaxError#path #3433

1 commit merged into from
Mar 19, 2024

Conversation

wasabigeek
Copy link
Contributor

@wasabigeek wasabigeek commented Feb 2, 2024

Attempt for [easy, java] SyntaxError#path has been added. [Feature #19138] as part of #3039.

There's already a sourceLocation in RubySyntaxError, which I believe is used to generate the message with filename: https://github.com/shopify/truffleruby/blob/add-syntaxerror-path/src/main/java/org/truffleruby/core/exception/CoreExceptions.java#L1015. This PR exposes that sourceLocation's filename directly (I think) as #path.

The original also has some handling for an existing SyntaxError's path being changed (diff), not sure if I needed to handle that.

Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Feb 2, 2024
@wasabigeek wasabigeek changed the title WIP WIP: Add SyntaxError#path Feb 2, 2024
@wasabigeek wasabigeek marked this pull request as ready for review February 2, 2024 08:52
@wasabigeek wasabigeek changed the title WIP: Add SyntaxError#path Add SyntaxError#path Feb 2, 2024
@wasabigeek wasabigeek force-pushed the add-syntaxerror-path branch 2 times, most recently from 5b06b00 to 9785f9f Compare February 2, 2024 09:34
Copy link

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Feb 5, 2024
@thomasmarshall
Copy link
Contributor

I noticed a small difference between MRI and the implementation here. When instantiating the error directly, in MRI the path method returns nil but with this change in TruffleRuby it returns "(unknown)". Maybe there could be a test similar to this one for LoadError :

it "is nil when constructed directly" do
@le.path.should == nil
end

@eregon
Copy link
Member

eregon commented Feb 12, 2024

Good point, I think CRuby never uses (unknown) or similar, so let's return nil in that case.
@wasabigeek Could you do that?


@TruffleBoundary
@Specialization
Object path(RubySyntaxError syntaxError) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to handle RubyString / Nil - a brief search of the codebase suggested that this was how we handled varying return types, did I miss something?

Copy link
Member

Choose a reason for hiding this comment

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

This is correct. Looks great!

@andrykonchin
Copy link
Member

Could you please squash working commits?

@wasabigeek
Copy link
Contributor Author

@andrykonchin squashed! 🙇

@andrykonchin andrykonchin added the in-ci The PR is being tested in CI. Do not push new commits. label Mar 18, 2024
@graalvmbot graalvmbot closed this pull request by merging all changes into oracle:master in a467c23 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. OCA Verified All contributors have signed the Oracle Contributor Agreement. shopify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants