-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
-Ysafe-init-global
not working with Scala 2 library TASTy
#18882
Comments
I'll take a look at it. Is it a blocker? |
Not yet |
These ones are also probematic
|
…ne numbers (#18930) Make sure that trace is shown correctly in the presence of invalid line numbers (-1) in TASTy. Before: ```Scala Reading mutable state of object Array during initialization of object Parent. Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: -> object Parent { // error [ t9312.scala:11 ] ^ -> final val children = Set(Child1, Child2) [ t9312.scala:21 ] ^^^^^^^^^^^^^^^^^^^ -> BitmapIndexedSetNode.this.originalHashes.apply(index) ``` After: ```Scala Reading mutable state of object Array during initialization of object Parent. Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: ├── object Parent { // error [ t9312.scala:11 ] │ ^ ├── final val children = Set(Child1, Child2) [ t9312.scala:21 ] │ ^^^^^^^^^^^^^^^^^^^ ├── scala.collection.IterableFactory.apply ├── IterableFactory.this.from[A](elems) ├── scala.collection.immutable.Set.from ├── scala.collection.immutable.Set.newBuilder[E].addAll(it) ├── scala.collection.immutable.SetBuilderImpl.addAll ├── super.addAll(xs) ├── scala.collection.mutable.Growable.addAll ├── Growable.this.addOne(it.next()) ├── scala.collection.immutable.SetBuilderImpl.addOne ├── SetBuilderImpl.this.hashSetBuilder.addOne(elem) ├── scala.collection.immutable.HashSetBuilder.addOne ├── HashSetBuilder.this.update(HashSetBuilder.this.rootNode, elem, h, im, 0) ├── scala.collection.immutable.HashSetBuilder.update ├── bm.getHash(index) ├── scala.collection.immutable.BitmapIndexedSetNode.getHash └── BitmapIndexedSetNode.this.originalHashes.apply(index) ``` Ref: #18882
Note that these tests are now blacklisted
To test them on the CI, remove them from the blacklist and use See #18892 |
Tried the latest master with sbt:scala3> set ThisBuild/Build.useScala2LibraryTasty := true
sbt:scala3> scala3-compiler-bootstrapped/scalac -Ysafe-init-global -d out tests/init-global/neg/t9312.scala And get a crash in loading the TASTy: TASTy file scala/LowPriorityImplicits.tasty is broken, reading aborted with class java.lang.ArrayIndexOutOfBoundsException
Index 6583 out of bounds for length 6583
Exception in thread "main" java.io.IOException: TASTy file scala/$less$colon$less.tasty is broken, reading aborted with class java.lang.ArrayIndexOutOfBoundsException
Index 9345 out of bounds for length 9345
at dotty.tools.dotc.core.TastyLoader.handleUnpicklingExceptions(SymbolLoaders.scala:448)
at dotty.tools.dotc.core.TastyLoader.<init>(SymbolLoaders.scala:423)
at dotty.tools.dotc.config.JavaPlatform.newTastyLoader(JavaPlatform.scala:71)
at dotty.tools.dotc.core.SymbolLoaders$.initializeFromClassPath(SymbolLoaders.scala:201)
at dotty.tools.dotc.core.SymbolLoaders$PackageLoader.enterClasses$$anonfun$1(SymbolLoaders.scala:276)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.VectorStatics$.foreachRec(Vector.scala:2124)
at scala.collection.immutable.Vector.foreach(Vector.scala:2130)
at dotty.tools.dotc.core.SymbolLoaders$PackageLoader.enterClasses(SymbolLoaders.scala:276)
at dotty.tools.dotc.core.SymbolLoaders$PackageLoader.doComplete$$anonfun$1$$anonfun$1(SymbolLoaders.scala:295)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at dotty.tools.dotc.core.SymbolLoaders$PackageLoader$PackageScope.lookupEntry(SymbolLoaders.scala:236)
at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.proceedWithEnter(SymDenotations.scala:2575)
at dotty.tools.dotc.core.SymDenotations$ClassDenotation.enter(SymDenotations.scala:2049)
at dotty.tools.dotc.core.Symbols$Symbol.entered(Symbols.scala:210)
at dotty.tools.dotc.core.Definitions.enterSpecialPolyClass(Definitions.scala:88)
at dotty.tools.dotc.core.Definitions.RepeatedParamClass(Definitions.scala:640)
at dotty.tools.dotc.core.Definitions.syntheticScalaClasses(Definitions.scala:2133)
at dotty.tools.dotc.core.Definitions.syntheticCoreClasses(Definitions.scala:2141)
at dotty.tools.dotc.core.Definitions.init(Definitions.scala:2157)
at dotty.tools.dotc.core.Contexts$ContextBase.initialize(Contexts.scala:902)
at dotty.tools.dotc.core.Contexts$Context.initialize(Contexts.scala:523)
at dotty.tools.dotc.Run.rootContext(Run.scala:450)
at dotty.tools.dotc.Run.<init>(Run.scala:471)
at dotty.tools.dotc.Compiler.newRun(Compiler.scala:172)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.dotc.Driver.process(Driver.scala:197)
at dotty.tools.dotc.Driver.process(Driver.scala:165)
at dotty.tools.dotc.Driver.process(Driver.scala:177)
at dotty.tools.dotc.Driver.main(Driver.scala:207)
at dotty.tools.dotc.Main.main(Main.scala)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 9345 out of bounds for length 9345
at dotty.tools.tasty.TastyReader.readLongNat(TastyReader.scala:78)
at dotty.tools.tasty.TastyReader.readNat(TastyReader.scala:64)
at dotty.tools.tasty.TastyReader.readNameRef(TastyReader.scala:118)
at dotty.tools.dotc.core.tasty.AttributeUnpickler.attributes$lzyINIT1(AttributeUnpickler.scala:24)
at dotty.tools.dotc.core.tasty.AttributeUnpickler.attributes(AttributeUnpickler.scala:14)
at dotty.tools.dotc.core.tasty.DottyUnpickler.$init$$$anonfun$1(DottyUnpickler.scala:61)
at scala.Option.map(Option.scala:242)
at dotty.tools.dotc.core.tasty.DottyUnpickler.<init>(DottyUnpickler.scala:61)
at dotty.tools.dotc.core.TastyLoader.$init$$$anonfun$1(SymbolLoaders.scala:423)
at dotty.tools.dotc.core.TastyLoader.handleUnpicklingExceptions(SymbolLoaders.scala:439)
... 32 more
It didn't happen in the previous reproduction of issue. Not sure if something has changed in between. Any ideas? /cc: @nicolasstucki |
@liufengyun clean your build. This is due to some additions to the TASTy attribute sections. |
The |
Problematic tests
tests/init-global/neg/patmat.scala
tests/init-global/neg/t9312.scala
tests/init-global/neg/unapplySeq-implicit-arg.scala
tests/init-global/neg/unapplySeq-implicit-arg2.scala
tests/init-global/neg/unapplySeq-implicit-arg3.scala
Reproduction 1
Reproduction 2
Without library TASTy
With library TASTy
Question
What trigers the extra warnings? It is possible that the TASTy has some inconsitent information. It is also possible that the TASTy has more information, for example, now we know which classes have a pure constuctor.
The text was updated successfully, but these errors were encountered: