|
| 1 | +class C with { |
| 2 | + // regular method foo |
| 3 | + fun foo(x) = x |
| 4 | +} |
| 5 | + |
| 6 | +module M with { |
| 7 | + // module method foo |
| 8 | + fun foo(x) = x |
| 9 | + // module method self that returns itself |
| 10 | + fun self(): module M = M |
| 11 | +} |
| 12 | +//│ FAILURE: Unexpected exception |
| 13 | +//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: keyword 'module' does not have right precedence |
| 14 | +//│ at: mlscript.utils.package$.lastWords(package.scala:211) |
| 15 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec$$anonfun$1(Keyword.scala:31) |
| 16 | +//│ at: scala.Option.getOrElse(Option.scala:201) |
| 17 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec(Keyword.scala:31) |
| 18 | +//│ at: hkmc2.syntax.Parser.parseRuleImpl(Parser.scala:351) |
| 19 | +//│ at: hkmc2.syntax.Parser.parseRule$$anonfun$2(Parser.scala:321) |
| 20 | +//│ at: hkmc2.syntax.Parser.wrap(Parser.scala:129) |
| 21 | +//│ at: hkmc2.syntax.Parser.parseRule(Parser.scala:321) |
| 22 | +//│ at: hkmc2.syntax.Parser.expr(Parser.scala:460) |
| 23 | +//│ at: hkmc2.syntax.Parser.exprContImpl(Parser.scala:921) |
| 24 | + |
| 25 | +:e |
| 26 | +fun f1(module m) |
| 27 | +//│ FAILURE: Unexpected exception |
| 28 | +//│ /!!!\ Uncaught error: scala.MatchError: TypeDef(Mod,Ident(m),None,None) (of class hkmc2.syntax.Tree$TypeDef) |
| 29 | +//│ at: hkmc2.semantics.Elaborator.param(Elaborator.scala:610) |
| 30 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$19(Elaborator.scala:614) |
| 31 | +//│ at: scala.collection.immutable.List.flatMap(List.scala:294) |
| 32 | +//│ at: hkmc2.semantics.Elaborator.params(Elaborator.scala:614) |
| 33 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$10(Elaborator.scala:484) |
| 34 | +//│ at: scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183) |
| 35 | +//│ at: scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179) |
| 36 | +//│ at: scala.collection.immutable.List.foldLeft(List.scala:79) |
| 37 | +//│ at: hkmc2.semantics.Elaborator.go$2(Elaborator.scala:483) |
| 38 | +//│ at: hkmc2.semantics.Elaborator.block$$anonfun$3(Elaborator.scala:597) |
| 39 | + |
| 40 | +:e |
| 41 | +fun f2[T](module m: T) |
| 42 | +//│ FAILURE: Unexpected exception |
| 43 | +//│ /!!!\ Uncaught error: scala.MatchError: TypeDef(Mod,InfixApp(Ident(m),keyword ':',Ident(T)),None,None) (of class hkmc2.syntax.Tree$TypeDef) |
| 44 | +//│ at: hkmc2.semantics.Elaborator.param(Elaborator.scala:610) |
| 45 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$19(Elaborator.scala:614) |
| 46 | +//│ at: scala.collection.immutable.List.flatMap(List.scala:294) |
| 47 | +//│ at: hkmc2.semantics.Elaborator.params(Elaborator.scala:614) |
| 48 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$10(Elaborator.scala:484) |
| 49 | +//│ at: scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183) |
| 50 | +//│ at: scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179) |
| 51 | +//│ at: scala.collection.immutable.List.foldLeft(List.scala:79) |
| 52 | +//│ at: hkmc2.semantics.Elaborator.go$2(Elaborator.scala:483) |
| 53 | +//│ at: hkmc2.semantics.Elaborator.block$$anonfun$3(Elaborator.scala:597) |
| 54 | + |
| 55 | +:e |
| 56 | +module N with { |
| 57 | + fun f3(): M = M |
| 58 | +} |
| 59 | +//│ ╔══[ERROR] Name not found: M |
| 60 | +//│ ║ l.57: fun f3(): M = M |
| 61 | +//│ ╙── ^ |
| 62 | +//│ ╔══[ERROR] Name not found: M |
| 63 | +//│ ║ l.57: fun f3(): M = M |
| 64 | +//│ ╙── ^ |
| 65 | + |
| 66 | +:e |
| 67 | +module N with { |
| 68 | + fun f4[T](): module T = M |
| 69 | +} |
| 70 | +//│ FAILURE: Unexpected exception |
| 71 | +//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: keyword 'module' does not have right precedence |
| 72 | +//│ at: mlscript.utils.package$.lastWords(package.scala:211) |
| 73 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec$$anonfun$1(Keyword.scala:31) |
| 74 | +//│ at: scala.Option.getOrElse(Option.scala:201) |
| 75 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec(Keyword.scala:31) |
| 76 | +//│ at: hkmc2.syntax.Parser.parseRuleImpl(Parser.scala:351) |
| 77 | +//│ at: hkmc2.syntax.Parser.parseRule$$anonfun$2(Parser.scala:321) |
| 78 | +//│ at: hkmc2.syntax.Parser.wrap(Parser.scala:129) |
| 79 | +//│ at: hkmc2.syntax.Parser.parseRule(Parser.scala:321) |
| 80 | +//│ at: hkmc2.syntax.Parser.expr(Parser.scala:460) |
| 81 | +//│ at: hkmc2.syntax.Parser.exprContImpl(Parser.scala:921) |
| 82 | + |
| 83 | +:e |
| 84 | +module N with { |
| 85 | + fun f5(): M = M |
| 86 | +} |
| 87 | +//│ ╔══[ERROR] Name not found: M |
| 88 | +//│ ║ l.85: fun f5(): M = M |
| 89 | +//│ ╙── ^ |
| 90 | +//│ ╔══[ERROR] Name not found: M |
| 91 | +//│ ║ l.85: fun f5(): M = M |
| 92 | +//│ ╙── ^ |
| 93 | + |
| 94 | + |
| 95 | +fun f6(m: M) |
| 96 | +//│ FAILURE: Unexpected type error |
| 97 | +//│ ╔══[ERROR] Name not found: M |
| 98 | +//│ ║ l.95: fun f6(m: M) |
| 99 | +//│ ╙── ^ |
| 100 | + |
| 101 | +:e |
| 102 | +f6(M) |
| 103 | +//│ ╔══[ERROR] Name not found: M |
| 104 | +//│ ║ l.102: f6(M) |
| 105 | +//│ ╙── ^ |
| 106 | + |
| 107 | +:e |
| 108 | +f6(M.self()) |
| 109 | +//│ ╔══[ERROR] Name not found: M |
| 110 | +//│ ║ l.108: f6(M.self()) |
| 111 | +//│ ╙── ^ |
| 112 | + |
| 113 | +:e |
| 114 | +fun f7(): module M |
| 115 | +//│ FAILURE: Unexpected exception |
| 116 | +//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: keyword 'module' does not have right precedence |
| 117 | +//│ at: mlscript.utils.package$.lastWords(package.scala:211) |
| 118 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec$$anonfun$1(Keyword.scala:31) |
| 119 | +//│ at: scala.Option.getOrElse(Option.scala:201) |
| 120 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec(Keyword.scala:31) |
| 121 | +//│ at: hkmc2.syntax.Parser.parseRuleImpl(Parser.scala:351) |
| 122 | +//│ at: hkmc2.syntax.Parser.parseRule$$anonfun$2(Parser.scala:321) |
| 123 | +//│ at: hkmc2.syntax.Parser.wrap(Parser.scala:129) |
| 124 | +//│ at: hkmc2.syntax.Parser.parseRule(Parser.scala:321) |
| 125 | +//│ at: hkmc2.syntax.Parser.expr(Parser.scala:460) |
| 126 | +//│ at: hkmc2.syntax.Parser.exprContImpl(Parser.scala:921) |
| 127 | + |
| 128 | + |
| 129 | +fun ok1(module m: M) |
| 130 | +//│ FAILURE: Unexpected exception |
| 131 | +//│ /!!!\ Uncaught error: scala.MatchError: TypeDef(Mod,InfixApp(Ident(m),keyword ':',Ident(M)),None,None) (of class hkmc2.syntax.Tree$TypeDef) |
| 132 | +//│ at: hkmc2.semantics.Elaborator.param(Elaborator.scala:610) |
| 133 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$19(Elaborator.scala:614) |
| 134 | +//│ at: scala.collection.immutable.List.flatMap(List.scala:294) |
| 135 | +//│ at: hkmc2.semantics.Elaborator.params(Elaborator.scala:614) |
| 136 | +//│ at: hkmc2.semantics.Elaborator.$anonfun$10(Elaborator.scala:484) |
| 137 | +//│ at: scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183) |
| 138 | +//│ at: scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179) |
| 139 | +//│ at: scala.collection.immutable.List.foldLeft(List.scala:79) |
| 140 | +//│ at: hkmc2.semantics.Elaborator.go$2(Elaborator.scala:483) |
| 141 | +//│ at: hkmc2.semantics.Elaborator.block$$anonfun$3(Elaborator.scala:597) |
| 142 | + |
| 143 | +module N with { |
| 144 | + fun ok2(): module M = M |
| 145 | +} |
| 146 | +//│ FAILURE: Unexpected exception |
| 147 | +//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: keyword 'module' does not have right precedence |
| 148 | +//│ at: mlscript.utils.package$.lastWords(package.scala:211) |
| 149 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec$$anonfun$1(Keyword.scala:31) |
| 150 | +//│ at: scala.Option.getOrElse(Option.scala:201) |
| 151 | +//│ at: hkmc2.syntax.Keyword.assumeRightPrec(Keyword.scala:31) |
| 152 | +//│ at: hkmc2.syntax.Parser.parseRuleImpl(Parser.scala:351) |
| 153 | +//│ at: hkmc2.syntax.Parser.parseRule$$anonfun$2(Parser.scala:321) |
| 154 | +//│ at: hkmc2.syntax.Parser.wrap(Parser.scala:129) |
| 155 | +//│ at: hkmc2.syntax.Parser.parseRule(Parser.scala:321) |
| 156 | +//│ at: hkmc2.syntax.Parser.expr(Parser.scala:460) |
| 157 | +//│ at: hkmc2.syntax.Parser.exprContImpl(Parser.scala:921) |
| 158 | + |
| 159 | +ok1(M) |
| 160 | +//│ FAILURE: Unexpected type error |
| 161 | +//│ ╔══[ERROR] Name not found: ok1 |
| 162 | +//│ ║ l.159: ok1(M) |
| 163 | +//│ ╙── ^^^ |
| 164 | +//│ FAILURE: Unexpected type error |
| 165 | +//│ ╔══[ERROR] Name not found: M |
| 166 | +//│ ║ l.159: ok1(M) |
| 167 | +//│ ╙── ^ |
| 168 | + |
| 169 | +ok1(M.self()) |
| 170 | +//│ FAILURE: Unexpected type error |
| 171 | +//│ ╔══[ERROR] Name not found: ok1 |
| 172 | +//│ ║ l.169: ok1(M.self()) |
| 173 | +//│ ╙── ^^^ |
| 174 | +//│ FAILURE: Unexpected type error |
| 175 | +//│ ╔══[ERROR] Name not found: M |
| 176 | +//│ ║ l.169: ok1(M.self()) |
| 177 | +//│ ╙── ^ |
0 commit comments