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

Compilation test failures with Scala 2 CC library TASTy #19652

Closed
nicolasstucki opened this issue Feb 9, 2024 · 10 comments · Fixed by #19873
Closed

Compilation test failures with Scala 2 CC library TASTy #19652

nicolasstucki opened this issue Feb 9, 2024 · 10 comments · Fixed by #19873
Assignees
Labels
area:experimental:cc Capture checking related itype:bug
Milestone

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Feb 9, 2024

#19603 fixes the basics and we can now compile most tests.

I tried to go further with

sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/testCompilation

Here's the current list of failures:

32 suites passed, 4 failed, 36 total
    tests/neg/i8988.scala failed
    tests/neg/abstract-givens.scala failed
    tests/neg/i18682.scala failed
    tests/run/enrich-gentraversable.scala failed
    tests/run/t5328.scala failed
    tests/run/xml.scala failed
    tests/run/t4332b.scala failed
    tests/run/abstract-givens.scala failed
    tests/run/t2552.scala failed
    tests/run/t2544.scala failed
    tests/run/i16459.scala failed
    tests/run/t6114.scala failed
    tests/pos/i18345.scala failed
    tests/run/t3269.scala failed
    tests/pos/spec-asseenfrom.scala failed
    tests/pos/i19009.case1.scala failed
    tests/pos/i14966a.scala failed
    tests/run/iterables.scala failed
    tests/run/i14582.scala failed
    tests/run/t4054.scala failed
    tests/pos/i14953.scala failed
    tests/run/t5201.scala failed
    tests/run/t6968.scala failed
    tests/run/range-unit.scala failed
    tests/pos/t5120.scala failed
    tests/run/t6271.scala failed
    tests/run/enrich-gentraversable.scala failed
    tests/pos/i1036.scala failed
    tests/pos/t6925.scala failed
    tests/run/Course-2002-10.scala failed
    tests/pos/tyql.scala failed
    tests/run/t4288.scala failed
    tests/run/main-annotation-newMain.scala failed
    tests/run/Pouring.scala failed
    tests/run/t5328.scala failed
    tests/run/t6628.scala failed
    tests/run/arrayview.scala failed
    tests/run/colltest1.scala failed
    tests/pos/gadt-accumulatable.scala failed
    tests/run/t3397.scala failed
    tests/run/t2544.scala failed
    tests/run/i16459.scala failed
    tests/run/t3516.scala failed
    tests/pos/tcpoly_ticket2096.scala failed
    tests/run/t4582.scala failed
    tests/run/i4523.scala failed
    tests/run/iterators.scala failed
    tests/run/stream-stack-overflow-filter-map.scala failed
    tests/pos/t4716.scala failed
    tests/run/streamWithFilter.scala failed
    tests/run/IArrayOps.scala failed
    tests/run/ReverseSeqView.scala failed
    tests/run/viewtest.scala failed
    tests/run/numbereq.scala failed
    tests/run/t3760.scala failed
    tests/run/distinct.scala failed
    tests/run/t4332b.scala failed
    tests/pos/i6199a.scala failed
    tests/run/view-headoption.scala failed
    tests/run/abstract-givens.scala failed
    tests/pos/i9967.scala failed
    tests/pos/i1777.scala failed
    tests/pos/StringContext.scala failed
    tests/run/t4954.scala failed
    tests/pos/i5418.scala failed
    tests/run/t6584.scala failed
    tests/run/extmethods2.scala failed
    tests/pos/t0068.scala failed
    tests/run/kmpSliceSearch.scala failed
    tests/run/patmat-bind-typed.scala failed
    tests/run/t1220.scala failed
    tests/run/t5867.scala failed
    tests/pos/syntaxRewrites.scala failed
    tests/run/forvaleq.scala failed
    tests/pos/t6205.scala failed
    tests/run/Pouring2.scala failed
    tests/run/unittest_iterator.scala failed
    tests/pos/indent-colons.scala failed
    tests/pos/t4717.scala failed
    tests/run/t2552.scala failed
    tests/run/lst failed
    tests/run/t5053.scala failed
    tests/run/lists-run.scala failed
    tests/run/t1074.scala failed
    tests/run/seqlike-kmp.scala failed
    tests/pos/tyql.scala failed
    tests/pos/t6925.scala failed

We need to follow up on this next.

Originally posted by @odersky in #19586 (comment)

@nicolasstucki nicolasstucki added cc-experiment Intended to be merged with cc-experiment branch on origin area:experimental:cc Capture checking related itype:bug labels Feb 9, 2024
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Feb 9, 2024

Minimization of tests/run/t5328.scala

// Test.scala
def test = Vector(1).view.updated(0,2)
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala
1 |def test = Vector(1).view.updated(0,2)
  |           ^^^^^^^^^^^^^^^^^^^^^^
  |     value updated is not a member of scala.collection.IndexedSeqView[Int]

@nicolasstucki
Copy link
Contributor Author

Orphan parameter while Ychecking with CC library.

Minimization of tests/pos/t6925.scala

class Test:
  def f(xs: Set[Int]) = xs collect { case x => x }
  def g(xs: Set[Int]): Set[Int] = f(xs)
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala -Ycheck:all
checking tests/pos/t6925.scala after phase typer

  exception while retyping def g(xs: Set[Int]): Set[Int] = this.f(xs) of class DefDef # -1

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: tests/pos/t6925.scala
        during phase: Ycheck
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.1-RC1-bin-SNAPSHOT-git-7bcfce2
            settings: -Vprint List(typer) -Ycheck List(all) -classpath /Users/nicolasstucki/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/nicolasstucki/Github/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.1-RC1-bin-SNAPSHOT.jar:/Users/nicolasstucki/Github/dotty/scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.1-RC1-bin-SNAPSHOT.jar -d /

*** error while checking tests/pos/t6925.scala after phase typer ***
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan param: xs.type, hash of binder = 1664998412, tree = <empty>, type = AnnotatedType(AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class collection)),object immutable),trait Set),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int))),ConcreteAnnotation(Apply(Select(New(Select(Select(Select(Ident(_root_),scala),annotation),retains)),<init>),List(Typed(SeqLiteral(List(This(Ident()), Ident(pf)),TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any)]),TypeTree[AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),<repeated>),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any)))])))))
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.transform.TreeChecker$$anon$2.apply(TreeChecker.scala:172)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:64)
        ...

@nicolasstucki
Copy link
Contributor Author

Minimization of tests/run/i4523.scala

class C:
  def foo = Seq(5).map { i => i }
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala -Ytest-pickler
  exception occurred while compiling List(tests/run/i4523.scala)

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: <no file>
        during phase: parser
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.1-RC1-bin-SNAPSHOT-git-7bcfce2
            settings: -Ytest-pickler true -classpath /Users/nicolasstucki/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/nicolasstucki/Github/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.1-RC1-bin-SNAPSHOT.jar:/Users/nicolasstucki/Github/dotty/scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.1-RC1-bin-SNAPSHOT.jar -d /

Exception in thread "main" scala.MatchError: AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class collection)),object immutable),Seq),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Int))) (of class dotty.tools.dotc.core.Types$CachedAppliedType)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readPathTree$1(TreeUnpickler.scala:1239)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readSimpleTree$1(TreeUnpickler.scala:1309)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$33(TreeUnpickler.scala:1474)
        at dotty.tools.tasty.TastyReader.until(TastyReader.scala:135)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1474)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        ...
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala -Yprint-tasty
-Yprint-tasty output
**** pickled info of class C
Header:
  version: 28.5.1
  tooling: Scala 3.4.1-RC1-bin-SNAPSHOT-git-7bcfce2
     UUID: 00f7ab37-0348-1ec0-00f7-e5d0d668eb32

Names (399 bytes, starting from 64):
     0: ASTs
     1: <empty>
     2: C
     3: <init>
     4: java
     5: lang
     6: java[Qualified . lang]
     7: Object
     8: java[Qualified . lang][Qualified . Object]
     9: <init>[Signed Signature(List(),java.lang.Object) @<init>]
    10: Unit
    11: scala
    12: foo
    13: Seq
    14: collection
    15: scala[Qualified . collection]
    16: immutable
    17: scala[Qualified . collection][Qualified . immutable]
    18: Int
    19: annotation
    20: scala[Qualified . annotation]
    21: retains
    22: scala[Qualified . annotation][Qualified . retains]
    23: scala[Qualified . collection][Qualified . immutable][Qualified . Seq]
    24: <init>[Signed Signature(List(scala.collection.immutable.Seq),scala.annotation.retains) @<init>]
    25: _root_
    26: Any
    27: f
    28: Function1
    29: <repeated>
    30: map
    31: scala[Qualified . Function1]
    32: map[Signed Signature(List(1, scala.Function1),java.lang.Object) @map]
    33: apply
    34: SeqOps
    35: scala[Qualified . collection][Qualified . SeqOps]
    36: apply[Signed Signature(List(1, scala.collection.immutable.Seq),scala.collection.SeqOps) @apply]
    37: package
    38: Delegate
    39: SeqFactory
    40: SeqFactory[ModuleClass]
    41: IterableOps
    42: $anonfun
    43: i
    44: SourceFile
    45: internal
    46: scala[Qualified . annotation][Qualified . internal]
    47: scala[Qualified . annotation][Qualified . internal][Qualified . SourceFile]
    48: String
    49: java[Qualified . lang][Qualified . String]
    50: <init>[Signed Signature(List(java.lang.String),scala.annotation.internal.SourceFile) @<init>]
    51: tests/run/i4523.scala
    52: Positions
    53: Comments
    54: Attributes


Trees (194 bytes, starting from 466):
     0: PACKAGE(191)
     3:   TERMREFpkg 1 [<empty>]
     5:   TYPEDEF(186) 2 [C]
     9:     TEMPLATE(162)
    12:       APPLY(10)
    14:         SELECTin(8) 9 [<init>[Signed Signature(List(),java.lang.Object) @<init>]]
    17:           NEW
    18:             TYPEREF 7 [Object]
    20:               TERMREFpkg 6 [java[Qualified . lang]]
    22:           SHAREDtype 18
    24:       DEFDEF(7) 3 [<init>]
    27:         EMPTYCLAUSE
    28:         TYPEREF 10 [Unit]
    30:           TERMREFpkg 11 [scala]
    32:         STABLE
    33:       DEFDEF(138) 12 [foo]
    37:         ANNOTATEDtype(58)
    39:           APPLIEDtype(8)
    41:             TYPEREF 13 [Seq]
    43:               TERMREFpkg 17 [scala[Qualified . collection][Qualified . immutable]]
    45:             TYPEREF 18 [Int]
    47:               SHAREDtype 30
    49:           APPLY(46)
    51:             SELECTin(14) 24 [<init>[Signed Signature(List(scala.collection.immutable.Seq),scala.annotation.retains) @<init>]]
    54:               NEW
    55:                 SELECTtpt 21 [retains]
    57:                   SELECT 19 [annotation]
    59:                     SELECT 11 [scala]
    61:                       TERMREFpkg 25 [_root_]
    63:               TYPEREF 21 [retains]
    65:                 TERMREFpkg 20 [scala[Qualified . annotation]]
    67:             TYPED(28)
    69:               REPEATED(18)
    71:                 TYPEREF 26 [Any]
    73:                   TERMREFpkg 11 [scala]
    75:                 SHAREDtype 39
    77:                 IDENT 27 [f]
    79:                   APPLIEDtype(8)
    81:                     TYPEREF 28 [Function1]
    83:                       SHAREDtype 30
    85:                     SHAREDtype 45
    87:                     SHAREDtype 45
    89:               APPLIEDtype(6)
    91:                 TYPEREF 29 [<repeated>]
    93:                   SHAREDtype 73
    95:                 SHAREDtype 71
    97:         APPLY(75)
    99:           TYPEAPPLY(47)
   101:             SELECTin(43) 32 [map[Signed Signature(List(1, scala.Function1),java.lang.Object) @map]]
   104:               APPLY(36)
   106:                 TYPEAPPLY(18)
   108:                   SELECTin(14) 36 [apply[Signed Signature(List(1, scala.collection.immutable.Seq),scala.collection.SeqOps) @apply]]
   111:                     TERMREF 13 [Seq]
   113:                       TERMREF 37 [package]
   115:                         SHAREDtype 30
   117:                     TYPEREF 38 [Delegate]
   119:                       THIS
   120:                         TYPEREF 40 [SeqFactory[ModuleClass]]
   122:                           TERMREFpkg 15 [scala[Qualified . collection]]
   124:                   SHAREDtype 45
   126:                 TYPED(14)
   128:                   REPEATED(4)
   130:                     SHAREDtype 45
   132:                     INTconst 5
   134:                   APPLIEDtype(6)
   136:                     TYPEREF 29 [<repeated>]
   138:                       SHAREDtype 30
   140:                     SHAREDtype 45
   142:               TYPEREF 41 [IterableOps]
   144:                 SHAREDtype 122
   146:             SHAREDtype 45
   148:           BLOCK(24)
   150:             BLOCK(22)
   152:               LAMBDA(3)
   154:                 TERMREFdirect 157
   157:               DEFDEF(15) 42 [$anonfun]
   160:                 PARAM(3) 43 [i]
   163:                   SHAREDtype 45
   165:                 SHAREDtype 45
   167:                 BLOCK(3)
   169:                   TERMREFdirect 160
   172:                 SYNTHETIC
   173:                 ARTIFACT
   174:     ANNOTATION(18)
   176:       TYPEREF 44 [SourceFile]
   178:         TERMREFpkg 46 [scala[Qualified . annotation][Qualified . internal]]
   180:       APPLY(12)
   182:         SELECTin(8) 50 [<init>[Signed Signature(List(java.lang.String),scala.annotation.internal.SourceFile) @<init>]]
   185:           NEW
   186:             SHAREDtype 176
   189:           SHAREDtype 176
   192:         STRINGconst 51 [tests/run/i4523.scala]
   194:

Positions (86 bytes, starting from 662):
  lines: 4
  line sizes:
     0, 8, 33, 0
  positions:
     0: 1 .. 43
     5: 1 .. 43
     9: 12 .. 43
    18: 7 .. 7
    24: 12 .. 12
    28: 12 .. 12
    33: 12 .. 43
    37: 19 .. 19
   101: 22 .. 32
   104: 22 .. 28
   111: 22 .. 25
   124: 22 .. 25
   130: 27 .. 27
   132: 26 .. 27
   134: 27 .. 27
   146: 22 .. 32
   148: 33 .. 43
   154: 41 .. 41
   157: 35 .. 41
   160: 35 .. 36
   163: 36 .. 36
   165: 36 .. 36
   169: 40 .. 41
   180: 1 .. 43
   186: 1 .. 1
   192: 1 .. 1

  source paths:
     0: 51 [tests/run/i4523.scala]


Attributes (2 bytes, starting from 752):
  SOURCEFILEattr 51 [tests/run/i4523.scala]

**** end of pickled info of class C

@odersky
Copy link
Contributor

odersky commented Feb 9, 2024

@Linyxus Could you take a look at the failures and see what can be done to fix them?

@odersky odersky removed their assignment Feb 9, 2024
@Linyxus
Copy link
Contributor

Linyxus commented Feb 9, 2024

Sure, I'll do that

@nicolasstucki
Copy link
Contributor Author

@Linyxus I will create a separate issue for each of the minimizations. This way discussions can be held on each individual issue.

@Linyxus
Copy link
Contributor

Linyxus commented Feb 28, 2024

After fixing #19660, #19661 and #19662, we are left with the following issues:

33 suites passed, 3 failed, 36 total
    tests/neg/abstract-givens.scala failed
    tests/neg/i8988.scala failed
    tests/neg/multi-file-error failed
    tests/neg/i18682.scala failed
    tests/neg/syntax-error-recovery.scala failed
    tests/run/enrich-gentraversable.scala failed
    tests/run/t5328.scala failed
    tests/run/xml.scala failed
    tests/run/t4332b.scala failed
    tests/run/abstract-givens.scala failed
    tests/run/i16458.scala failed
    tests/run/t2552.scala failed
    tests/run/t2544.scala failed
    tests/run/i16459.scala failed
    tests/run/t2552.scala failed
    tests/run/enrich-gentraversable.scala failed
    tests/run/t4332b.scala failed
    tests/run/t5328.scala failed

I'll look into them.

@Linyxus
Copy link
Contributor

Linyxus commented Feb 28, 2024

I minimised a issue that seems to be related to the runtime #19819, which I don't really know how to debug. /cc @nicolasstucki could you maybe have a look at this one? thanks! :)

Linyxus added a commit that referenced this issue Feb 28, 2024
Only test a subset of tests that are known to currently work.

[test_scala2_library_tasty]

All `pos` tests work now. We will increase coverage to all tests once
failures in
#19652 (comment)
are fixed.
@Linyxus
Copy link
Contributor

Linyxus commented Mar 1, 2024

Minimised another runtime-related issue #19845.

@Linyxus
Copy link
Contributor

Linyxus commented Mar 1, 2024

I opened another ticket tracking the checkfile issue I mentioned to @odersky today: #19847.

Linyxus added a commit that referenced this issue Mar 6, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants