Skip to content

Add error-checking when fetching rhs of trees from TASTy #22565

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

lidaisy
Copy link
Contributor

@lidaisy lidaisy commented Feb 9, 2025

This PR would fix the error raised in #22442.
The error arises when reading incompatible TASTy trees. This PR checks if an error occurs when fetching the rhs of ValOrDefDef trees and gives a warning.

@lidaisy lidaisy changed the title Add error-checking when fetching rhs of trees TASTy Add error-checking when fetching rhs of trees from TASTy Feb 10, 2025
Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

LGTM, but @liufengyun , do you also want to take a look?

@olhotak olhotak requested a review from liufengyun February 25, 2025 15:41
@olhotak olhotak marked this pull request as ready for review February 25, 2025 15:41
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @lidaisy !

Let's squash the commits into one commit to make the history clean. In particular, avoid creating unnecessary merge commits in a PR (rebase is preferred).

/* This tests for errors in the program's TASTy trees.
* The test consists of three files: (a) v1/A, (b) v1/B, and (c) v0/A. (a) and (b) are
* compatible, but (b) and (c) are not. If (b) and (c) are compiled together, there should be
* an error when reading the files' TASTy trees. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: the * and comments are not aligned.


val a0 = defaultOutputDir + tastyErrorGroup + "/A/v0/A"
val a1 = defaultOutputDir + tastyErrorGroup + "/A/v1/A"
val b1 = defaultOutputDir + tastyErrorGroup + "/B/v1/B"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: the names a0, a1 and b1 are not informative.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of assuming the output directory format, for maintainability, it would be better to explicitly set output directory based on the defaultOutputDir.

Fewer assumptions are better --- it causes fewer problems in case the format changes.

compileFile("tests/init/tasty-error/v1/B.scala", tastyErrorOptions.withClasspath(a1))(tastyErrorGroup),
compileFile("tests/init/tasty-error/v0/A.scala", tastyErrorOptions)(tastyErrorGroup),
).map(_.keepOutput.checkCompile())
compileFile("tests/init/tasty-error/Main.scala", tastyErrorOptions.withClasspath(a0).withClasspath(b1))(tastyErrorGroup).checkExpectedErrors()
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: add one blank line before line 284 for better readability.

@olhotak olhotak merged commit 4a85e27 into scala:main Mar 5, 2025
29 checks passed
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
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.

4 participants