Skip to content

Commit 39fb4df

Browse files
jiribenesb-studiosphischu
authored
Disable subtyping, introduce coercions, and type check core (#1219)
See the PR comments. --------- Co-authored-by: Jonathan Brachthäuser <jonathan@b-studios.de> Co-authored-by: Philipp Schuster <philipp.schuster@uni-tuebingen.de>
1 parent 53cc164 commit 39fb4df

File tree

71 files changed

+1351
-1646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1351
-1646
lines changed

.jvmopts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
-Xms1g
12
-Xmx4g
2-
-Xms1g
3+
-Xss32m
4+
-Xmx8g

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
158158
val osName = System.getProperty("os.name").toLowerCase
159159
val shebang =
160160
if (osName.contains("win"))
161-
"#! /usr/bin/env java -jar\n"
161+
"#! /usr/bin/env java -Xss32m -jar\n"
162162
else
163-
"#! /usr/bin/env -S java -jar\n"
163+
"#! /usr/bin/env -S java -Xss32m -jar\n"
164164

165165
IO.write(binary, shebang)
166166
IO.append(binary, IO.readBytes(jarfile))

effekt/jvm/src/main/scala/effekt/Runner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ object LLVMRunner extends Runner[String] {
298298

299299
override def includes(path: File): List[File] = List(path / ".." / "llvm")
300300

301-
lazy val clangCmd = discoverExecutable(List("clang-20", "clang-19", "clang-18", "clang"), List("--version"))
301+
lazy val clangCmd = discoverExecutable(List("clang-21", "clang-20", "clang-19", "clang-18", "clang"), List("--version"))
302302

303303
def checkSetup(): Either[String, Unit] =
304304
clangCmd.getOrElseAborting { return Left("Cannot find clang. This is required to use the LLVM backend.") }

effekt/jvm/src/test/scala/effekt/LSPTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ class LSPTests extends FunSuite {
14381438
| Nil,
14391439
| Nil,
14401440
| List(
1441-
| Val(foo_whatever, Data(Int_whatever, Nil), Return(Literal(42, Data(Int_whatever, Nil))))
1441+
| Val(foo_whatever, Return(Literal(42, Data(Int_whatever, Nil))))
14421442
| ),
14431443
| List(foo_whatever)
14441444
|)""".stripMargin

effekt/jvm/src/test/scala/effekt/core/OptimizerTests.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class OptimizerTests extends CoreTests {
151151
test("inline toplevel"){
152152
val input =
153153
""" def foo = { () => return 42 }
154-
| def main = { () => (foo : () => Unit @ {})() }
154+
| def main = { () => (foo : () => Int @ {})() }
155155
|""".stripMargin
156156

157157
val expected =
@@ -164,7 +164,7 @@ class OptimizerTests extends CoreTests {
164164
test("inline with argument"){
165165
val input =
166166
""" def foo = { (n: Int) => return n:Int }
167-
| def main = { () => (foo : (Int) => Unit @ {})(42) }
167+
| def main = { () => (foo : (Int) => Int @ {})(42) }
168168
|""".stripMargin
169169

170170
val expected =
@@ -181,7 +181,7 @@ class OptimizerTests extends CoreTests {
181181
| (f : (Int) => Int @ {f})(1)
182182
| }
183183
| def main = { () =>
184-
| (hof : (){f : (Int) => Int} => Int @ {})(){ (foo : (Int) => Unit @ {}) }
184+
| (hof : (){f : (Int) => Int} => Int @ {})(){ (foo : (Int) => Int @ {}) }
185185
| }
186186
|""".stripMargin
187187

@@ -199,7 +199,7 @@ class OptimizerTests extends CoreTests {
199199
| (f : (Int) => Int @ {f})(1)
200200
| }
201201
| def main = { () =>
202-
| (hof : (){f : (Int) => Int} => Int @ {})(){ (foo : (Int) => Unit @ {}) }
202+
| (hof : (){f : (Int) => Int} => Int @ {})(){ (foo : (Int) => Int @ {}) }
203203
| }
204204
|""".stripMargin
205205

effekt/jvm/src/test/scala/effekt/core/PatternMatchingTests.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package effekt
22
package core
33
import effekt.symbols
44
import kiama.util.StringSource
5-
65
import PatternMatchingCompiler.*
7-
import core.Type.{TBoolean, TInt, TUnit}
6+
import core.Type.{ TBoolean, TInt, TString, TUnit }
87

98
class PatternMatchingTests extends CoreTests {
109

@@ -47,7 +46,7 @@ class PatternMatchingTests extends CoreTests {
4746
}
4847

4948
test("Sanity check: compiling empty list of clauses") {
50-
assertEquals(compile(Nil), core.Hole(effekt.source.Span.missing))
49+
assertEquals(compile(Nil, TUnit), core.Hole(TUnit, effekt.source.Span.missing))
5150
}
5251

5352
test("Simple guard") {
@@ -71,16 +70,16 @@ class PatternMatchingTests extends CoreTests {
7170
Clause(
7271
List(
7372
Condition.Patterns(Map(sc -> Pattern.Any(x.id))),
74-
Condition.Val(p.id, TBoolean, trivalPredicate),
73+
Condition.Val(p.id, trivalPredicate),
7574
Condition.Predicate(p)),
7675
b1, Nil, List(x)),
7776
Clause(
7877
List(
7978
Condition.Patterns(Map(sc -> Pattern.Ignore()))),
80-
b2, Nil, List())))
79+
b2, Nil, List())), TString)
8180

8281
val expected =
83-
Val(p.id, TBoolean, trivalPredicate,
82+
Val(p.id, trivalPredicate,
8483
If(p,
8584
jump(b1, sc),
8685
jump(b2)))
@@ -125,21 +124,21 @@ class PatternMatchingTests extends CoreTests {
125124
Clause(
126125
List(
127126
Condition.Patterns(Map(opt -> Pattern.Tag(SomeC, List(), List(SomeC, NoneC), List(Pattern.Any(v.id) -> TInt)))),
128-
Condition.Val(p.id, TBoolean, trivalPredicate),
127+
Condition.Val(p.id, trivalPredicate),
129128
Condition.Predicate(p)),
130129
b1, Nil, List(v)),
131130
Clause(
132131
List(
133132
Condition.Patterns(Map(opt -> Pattern.Ignore()))),
134-
b2, Nil, List())))
133+
b2, Nil, List())), TUnit)
135134

136135
// opt match {
137136
// case Some(tmp) => val p = return v > 0; if (p) { b1(tmp) } else { b2() }
138137
// case _ => b2()
139138
// }
140-
val expected = Match(opt,
139+
val expected = Match(opt, TUnit,
141140
List((SomeC, BlockLit(Nil, Nil, List(ValueParam(tmp.id, tmp.tpe)), Nil,
142-
Val(p.id, TBoolean, trivalPredicate, If(p,
141+
Val(p.id, trivalPredicate, If(p,
143142
App(b1, Nil, List(tmp), Nil),
144143
App(b2, Nil, Nil, Nil)))))),
145144
Some(App(b2, Nil, Nil, Nil)))

effekt/jvm/src/test/scala/effekt/core/PolymorphismBoxingTests.scala

Lines changed: 0 additions & 176 deletions
This file was deleted.

effekt/jvm/src/test/scala/effekt/core/RenamerTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class RenamerTests extends CoreTests {
128128
|
129129
|type Data { X(a:Int, b:Int) }
130130
|def foo = { () =>
131-
| 12 match {
131+
| 12 match [Int] {
132132
| X : {(aa:Int, bb:Int) => return aa:Int }
133133
| }
134134
|}
@@ -141,7 +141,7 @@ class RenamerTests extends CoreTests {
141141
val code =
142142
"""module main
143143
|
144-
|def foo = { ['A](a: A) =>
144+
|def foo = { ['A](a: Identity[A]) =>
145145
| return a:Identity[A]
146146
|}
147147
|""".stripMargin

effekt/jvm/src/test/scala/effekt/core/ReparseTests.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ class ReparseTests extends CoreTests {
7676
val renamer = TestRenamer(Names(defaultNames))
7777
val expectedRenamed = renamer(coreMod)
7878
val printed = core.PrettyPrinter.format(expectedRenamed).layout
79-
val reparsed: ModuleDecl = parse(printed)(using Location.empty)
79+
val reparsed: ModuleDecl = try { parse(printed)(using Location.empty) } catch {
80+
case e @ TypeError(msg, context) =>
81+
println(e.toString)
82+
throw e
83+
case e =>
84+
println("Error while re-parsing:")
85+
println(printed)
86+
throw e
87+
}
8088
val reparsedRenamed = renamer(reparsed)
8189
val reparsedPrinted = core.PrettyPrinter.format(reparsedRenamed).layout
8290
val expectedPrinted = core.PrettyPrinter.format(expectedRenamed).layout

0 commit comments

Comments
 (0)