Skip to content

Commit 790faa2

Browse files
committed
propagated better error messages for undefnied term to tests
1 parent 2e664b9 commit 790faa2

File tree

8 files changed

+187
-34
lines changed

8 files changed

+187
-34
lines changed

hkmc2/shared/src/main/scala/hkmc2/utils/Scope.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class Scope
9999
raise(ErrorReport(msg"No definition found in scope for '${l.nme}'" -> loc :: Nil,
100100
extraInfo = Some(l -> l.getClass),
101101
source = Diagnostic.Source.Compilation))
102-
source = Diagnostic.Source.Compilation))
103102
l.nme
104103

105104
def allocateName(l: Local, prefix: Str = ""): Str =

hkmc2/shared/src/test/mlscript/backlog/Lifter.mls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fun foo(x, y) =
158158
fun foo = M.foo()
159159
foo
160160
//│ ═══[WARNING] Modules are not yet lifted.
161-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:M (class hkmc2.semantics.BlockMemberSymbol)
161+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'M'
162162
//│ ║ l.154: module M with
163163
//│ ╙── ^
164164

@@ -186,7 +186,7 @@ fun foo(x) =
186186
class Bar extends Foo
187187
(new Bar).self2
188188
foo(2)
189-
//│ ═══[COMPILATION ERROR] No definition found in scope for: Foo$ (class hkmc2.semantics.VarSymbol)
189+
//│ ═══[COMPILATION ERROR] No definition found in scope for 'Foo$'
190190
//│ ═══[RUNTIME ERROR] TypeError: Foo1 is not a function
191191

192192
// `h` is lifted out, but then cannot access the BlockMemberSymbol M.
@@ -198,6 +198,6 @@ fun f =
198198
h
199199
M.g
200200
//│ ═══[WARNING] Modules are not yet lifted.
201-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:M (class hkmc2.semantics.BlockMemberSymbol)
201+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'M'
202202
//│ ║ l.195: module M with
203203
//│ ╙── ^

hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ f of
164164
fun p: Int
165165

166166
p
167-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:p (class hkmc2.semantics.BlockMemberSymbol)
167+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'p'
168168
//│ ║ l.164: fun p: Int
169169
//│ ╙── ^^^^^^
170170
//│ ═══[RUNTIME ERROR] ReferenceError: p is not defined
@@ -177,14 +177,14 @@ fun (++) test: (Int, Int) -> Int
177177
//│ test -> RefElem(member:test)
178178

179179
test(1, 2)
180-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:test (class hkmc2.semantics.BlockMemberSymbol)
180+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'test'
181181
//│ ║ l.174: fun (++) test: (Int, Int) -> Int
182182
//│ ╙── ^^^^^^^^^^^^^^^^^^^^^
183183
//│ ═══[RUNTIME ERROR] ReferenceError: test is not defined
184184

185185
:sjs
186186
1 ++ 1
187-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:test (class hkmc2.semantics.BlockMemberSymbol)
187+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'test'
188188
//│ ║ l.174: fun (++) test: (Int, Int) -> Int
189189
//│ ╙── ^^^^^^^^^^^^^^^^^^^^^
190190
//│ JS (unsanitized):
@@ -276,7 +276,7 @@ let xs = new Oopsie
276276
//│ ╔══[ERROR] Name not found: Oopsie
277277
//│ ║ l.275: let xs = new Oopsie
278278
//│ ╙── ^^^^^^
279-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: xs (class hkmc2.semantics.VarSymbol)
279+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'xs'
280280
//│ ║ l.275: let xs = new Oopsie
281281
//│ ╙── ^^
282282
//│ ═══[RUNTIME ERROR] ReferenceError: xs is not defined

hkmc2/shared/src/test/mlscript/basics/Records.mls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let rcd =
7878
//│ ╔══[ERROR] Name not found: bar
7979
//│ ║ l.73: bar =
8080
//│ ╙── ^^^
81-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: rcd (class hkmc2.semantics.VarSymbol)
81+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'rcd'
8282
//│ ║ l.71: let rcd =
8383
//│ ╙── ^^^
8484
//│ rcd = {foo: 1, bar: "..."}

hkmc2/shared/src/test/mlscript/codegen/PartialApps.mls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ _ + 1 >> _ * 2 <| 123
9090
:todo
9191
let j = _.x
9292
//│ ═══[ERROR] Illegal position for '_' placeholder.
93-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: j (class hkmc2.semantics.VarSymbol)
93+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'j'
9494
//│ ║ l.91: let j = _.x
9595
//│ ╙── ^
9696
//│ ═══[RUNTIME ERROR] ReferenceError: j is not defined
9797

9898
:todo
9999
let j = _.x(123)
100100
//│ ═══[ERROR] Illegal position for '_' placeholder.
101-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: j (class hkmc2.semantics.VarSymbol)
101+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'j'
102102
//│ ║ l.99: let j = _.x(123)
103103
//│ ╙── ^
104104
//│ ═══[RUNTIME ERROR] ReferenceError: j is not defined

hkmc2/shared/src/test/mlscript/ctx/MissingDefinitions.mls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ g(5)
1212
:ge
1313
:re
1414
f(1)
15-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:f (class hkmc2.semantics.BlockMemberSymbol)
15+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'f'
1616
//│ ║ l.3: fun f: Any -> Any
1717
//│ ╙── ^^^^^^^^^^^^^
1818
//│ ═══[RUNTIME ERROR] ReferenceError: f is not defined
@@ -25,6 +25,6 @@ fun g(x) = f(x)
2525
:js
2626
:ge
2727
fun g(x) = f(x)
28-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:f (class hkmc2.semantics.BlockMemberSymbol)
28+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'f'
2929
//│ ║ l.3: fun f: Any -> Any
3030
//│ ╙── ^^^^^^^^^^^^^

hkmc2/shared/src/test/mlscript/ctx/TrickyResolution.mls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use Bar[Str] = new Bar
2323
// * and thus picks the Bar[Int] instance
2424
:fixme
2525
foo
26-
//│ ╔══[COMPILATION ERROR] No definition found in scope for: member:foo (class hkmc2.semantics.BlockMemberSymbol)
26+
//│ ╔══[COMPILATION ERROR] No definition found in scope for 'foo'
2727
//│ ║ l.13: fun foo[A](using f: Foo[A], b: Bar[A]): A
2828
//│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2929
//│ ═══[RUNTIME ERROR] ReferenceError: foo is not defined

0 commit comments

Comments
 (0)