Skip to content

Conversation

shubhampatel6103
Copy link

@shubhampatel6103 shubhampatel6103 commented Jul 15, 2025

Added a safe value test for global object initialization that is not supposed to give warnings when compiled.
At the moment, the test is not working as expected and it is not generating warnings even with the incorrect init checker which should produce warnings.

[test_scala2_library_tasty]

compileFile("tests/init-global/pos-tasty/safe-value-tasty/def/SafeValuesDef.scala", tastyErrorOptions)(tastyErrorGroup),
).map(_.keepOutput.checkCompile())

compileFile("tests/init-global/pos-tasty/safe-value-tasty/SafeValuesUse.scala", tastyErrorOptions.withClasspath(outDirDef))(tastyErrorGroup).checkCompile()
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure the test is compiled with the option -Ysafe-init-global. Consider adding it to the option variable before

Copy link
Author

Choose a reason for hiding this comment

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

There are no different effects. The test still passes. Added the change to a new commit below

Copy link
Contributor

Choose a reason for hiding this comment

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

From the latest errors, it seems there is a problem with the class path:

-- [E006] Not Found Error: tests/init-global/pos-tasty/safe-value-tasty/SafeValuesUse.scala:3:2 ------------------------
3 |  TestSafeValues.BitPartitionSize
  |  ^^^^^^^^^^^^^^
  |  Not found: TestSafeValues

Copy link
Author

Choose a reason for hiding this comment

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

I don't seem to be getting that issue on my end. I used to get that error before but my path was incorrect so perhaps try pulling again? I am running with sbt testCompilation safe-value-tasty and I get the following

============================================================================

Test Report

============================================================================

2 suites passed, 0 failed, 2 total

val options = defaultOptions.and("-Wsafe-init", "-Xfatal-warnings", "-Ysafe-init-global")
val tastyErrorOptions = options.without("-Xfatal-warnings")

val outDirDef = defaultOutputDir + tastyErrorGroup + "/SafeValuesDef/safe-value-tasty/SafeValuesDef"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val outDirDef = defaultOutputDir + tastyErrorGroup + "/SafeValuesDef/safe-value-tasty/SafeValuesDef"
val outDirDef = defaultOutputDir + tastyErrorGroup + "/SafeValuesDef/def/SafeValuesDef"

This seems to be the correct directory path for the generated tasty files. I've found that toDouble in the tasty files has been regarded as method call trees in our checker, instead of selection trees before, so the test can pass now. Maybe the tasty disassembler has been updated and resolved this issue. There are no errors safe unexpected selections on base values in the latest logs, either.

Copy link
Author

Choose a reason for hiding this comment

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

I updated the path and still getting no errors. However, I get the error in Jason's previous test which was using the external library at tests/init-global/pos-tasty/test-safe-value.scala and I still get the following error:

-- Warning: out/bootstrap/scala2-library-bootstrapped/scala-3.7.3-RC1-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src/scala/collection/immutable/ChampCommon.scala:27:43
27 | final val MaxDepth = ceil(HashCodeLength.toDouble / BitPartitionSize).toInt
| ^^^^^^^^^^^^^^^^^^^^^^^
|[Internal error] Unexpected selection on safe value SafeValue of class Int, field = method toDouble. Calling trace:
|├── private[collection] object Node { [ ChampCommon.scala:20 ]
|│ ^
|└── final val MaxDepth = ceil(HashCodeLength.toDouble / BitPartitionSize).toInt [ ChampCommon.scala:27 ]
| ^^^^^^^^^^^^^^^^^^^^^^^
1 warning found

@EnzeXing
Copy link
Contributor

[test_scala2_library_tasty]

@olhotak
Copy link
Contributor

olhotak commented Aug 26, 2025

Closing in favour of #23424

@olhotak olhotak closed this Aug 26, 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.

5 participants