Skip to content

Commit ec5c55e

Browse files
committed
no disjoint upperbound
1 parent bf4c763 commit ec5c55e

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

hkmc2/shared/src/main/scala/hkmc2/bbml/ConstraintSolver.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ class ConstraintSolver(infVarState: InfVarUid.State, elState: Elaborator.State,
9292
cctx.nest(v -> nc) givenIn:
9393
v.state.upperBounds ::= nc
9494
v.state.lowerBounds.foreach(lb => constrainImpl(lb, nc))
95-
v.state.disjsub.foreach: d =>
96-
Type.disjoint(d.disjoint(v), bd.toBasic.simp.toBasic)(Set.empty)(using c = mutable.Map.empty)
97-
.foreach(_.foreach(k => DisjSub(d.disjoint ++ k, d.dss, d.cs).commit()))
9895
else
9996
log(s"New bound: ${v.showDbg} :> ${bd.showDbg}")
10097
cctx.nest(bd -> v) givenIn:

hkmc2/shared/src/main/scala/hkmc2/bbml/types.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,8 @@ object Type:
306306
case (v: InfVar, _) =>
307307
val p = prev + (v->b)
308308
val k = v.state.lowerBounds.map(lb => disjoint(lb.toBasic.simp.toBasic, b)(p))
309-
if k.exists(_.isEmpty) then N
310-
else
311-
val u = (k.flatten.flatten.toSet + Set.empty).map(_ + (v -> b))
312-
val w = v.state.upperBounds.flatMap(ub => disjoint(ub.toBasic.simp.toBasic, b)(p))
313-
S(w.fold(u)((x, y) => y.flatMap(y => x.map(_ ++ y))))
309+
if k.exists(_.isEmpty) then N
310+
else S((k.flatten.flatten.toSet + Set.empty).map(_ + (v -> b)))
314311
case (_, v: InfVar) => disjoint(v, a)(prev)
315312
case _ => N
316313
}) else N

hkmc2/shared/src/test/mlscript/bbml/DisjSub.mls

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ x=>
3838
//│ 'x <: Int ∨ Bool
3939
//│ 'x <: Int
4040
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
41+
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
4142

4243
fun ap1(f)=f(1)
4344
ap1(idIB)
@@ -58,17 +59,17 @@ x=>idIB(x)
5859
:todo // BbML
5960
fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6061
//│ ╔══[ERROR] General type is not allowed here.
61-
//│ ║ l.59: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
62+
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6263
//│ ╙── ^^^
6364
//│ ╔══[ERROR] General type is not allowed here.
64-
//│ ║ l.59: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
65+
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6566
//│ ╙── ^^^^
6667
//│ Type: ⊤
6768

6869
:todo // BbML
6970
idIIBB([1, 2])
7071
//│ ╔══[ERROR] Term shape not yet supported by BbML: Tup(List(Fld(‹›,Lit(IntLit(1)),None), Fld(‹›,Lit(IntLit(2)),None)))
71-
//│ ║ l.69: idIIBB([1, 2])
72+
//│ ║ l.70: idIIBB([1, 2])
7273
//│ ╙── ^^^^^^
7374
//│ Type: ⊥
7475

@@ -98,8 +99,8 @@ idIIBB(new Pair(1, true))
9899
:todo
99100
fun foo: ["x": Int, "y": Int]
100101
//│ ╔══[ERROR] Invalid type
101-
//│ ║ l.99: fun foo: ["x": Int, "y": Int]
102-
//│ ╙── ^^^^^^^^^^^^^^^^^^^^
102+
//│ ║ l.100: fun foo: ["x": Int, "y": Int]
103+
//│ ╙── ^^^^^^^^^^^^^^^^^^^^
103104
//│ Type: ⊤
104105

105106
foo

hkmc2/shared/src/test/mlscript/bbml/bbBounds.mls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bazbaz
8787
//│ Type: ['A] -> ('A) ->{⊥} ('A -> 'A) ->{⊥} 'A
8888
//│ Where:
8989
//│ 'A <: Int
90-
//│ 'A#Int ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
90+
//│ 'A#'A ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
9191

9292
bazbaz(42)(x => x + 1)
9393
//│ Type: Int
@@ -119,14 +119,14 @@ bazbaz as [A extends Int] -> A -> ([B extends A -> A restricts A -> A] -> B) ->
119119
//│ Type: ['A] -> ('A) ->{⊥} ('A -> 'A) ->{⊥} 'A
120120
//│ Where:
121121
//│ 'A <: Int
122-
//│ 'A#Int ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
122+
//│ 'A#'A ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
123123

124124

125125
(x => f => bazbaz(x)(f)) as [A extends Int] -> A -> ([B extends A -> A restricts A -> A] -> B) -> A
126126
//│ Type: ['A] -> ('A) ->{⊥} ('A -> 'A) ->{⊥} 'A
127127
//│ Where:
128128
//│ 'A <: Int
129-
//│ 'A#Int ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
129+
//│ 'A#'A ∨ 'A<:'A ∧ ⊥<:⊥ ∧ 'A<:'A}
130130

131131

132132
h(x => f => bazbaz(x)(f))(42)

hkmc2/shared/src/test/mlscript/bbml/bbCyclicExtrude.mls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let foo(f) = (f(x => x(x)) as [A] -> A -> A) in foo
4040
:todo
4141
fun foo(f) = (f(x => x(x)) as [A] -> A -> A)
4242
//│ ╔══[ERROR] Expected a monomorphic type or an instantiable type here, but ('f) ->{⊥} [outer, 'A] -> ('A) ->{⊥} 'A found
43-
//│ ║ l.42: fun foo(f) = (f(x => x(x)) as [A] -> A -> A)
43+
//│ ║ l.41: fun foo(f) = (f(x => x(x)) as [A] -> A -> A)
4444
//│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545
//│ Type: ⊤
4646

0 commit comments

Comments
 (0)