Skip to content

Commit e215321

Browse files
committed
Better error messages for unmatched callable arity
1 parent b9f5b36 commit e215321

File tree

12 files changed

+26
-18
lines changed

12 files changed

+26
-18
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
type Foo {}
22

3-
var foo = Foo(1, 2, 3) # error: Runtime error: Expected 0 arguments but got 3.
3+
var foo = Foo(1, 2, 3) # error: Runtime error: Type 'Foo' expected 0 arguments but got 3.

spec/e2e/constructor/extra_arguments.lit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ type Foo {
55
}
66
}
77

8-
var foo = Foo(1, 2, 3, 4) # error: Runtime error: Expected 2 arguments but got 4.
8+
var foo = Foo(1, 2, 3, 4) # error: Runtime error: Type 'Foo' expected 2 arguments but got 4.

spec/e2e/constructor/missing_arguments.lit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ type Foo {
22
init { |a, b|}
33
}
44

5-
var foo = Foo(1) # error: Runtime error: Expected 2 arguments but got 1.
5+
var foo = Foo(1) # error: Runtime error: Type 'Foo' expected 2 arguments but got 1.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
fn existing do |a| it # error: Syntax error at "it": Default parameter can't be used when explicit parameters are defined.
22
existing(1)
33

4-
fn missing do it
5-
missing() # errfor: Runtime error: Expected 1 argument, but got 0.
6-
74
fn multiline {
85
println(it) # error: Syntax error at "it": Default parameter can't be used with multi-line blocks.
96
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fn missing do it
2+
missing() # error: Runtime error: Function 'missing' expected 1 argument but got 0.

spec/e2e/function/extra_arguments.lit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ fn f { |a, b|
33
println(b)
44
}
55

6-
f(1, 2, 3, 4) # error: Runtime error: Expected 2 arguments but got 4.
6+
f(1, 2, 3, 4) # error: Runtime error: Function 'f' expected 2 arguments but got 4.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn f { |a, b| }
22

3-
f(1) # error: Runtime error: Expected 2 arguments but got 1.
3+
f(1) # error: Runtime error: Function 'f' expected 2 arguments but got 1.

spec/e2e/method/extra_arguments.lit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ type Foo {
55
}
66
}
77

8-
Foo().method(1, 2, 3, 4) # error: Runtime error: Expected 2 arguments but got 4.
8+
Foo().method(1, 2, 3, 4) # error: Runtime error: Method 'method' expected 2 arguments but got 4.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type Foo {
2-
method { |a, b|}
2+
mtd { |a, b|}
33
}
44

5-
Foo().method(1) # error: Runtime error: Expected 2 arguments but got 1.
5+
Foo().mtd(1) # error: Runtime error: Method 'mtd' expected 2 arguments but got 1.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
fn no_op {}
2-
1 |> no_op() # error: Runtime error: Expected 0 arguments but got 1.
2+
1 |> no_op() # error: Runtime error: Function 'no_op' expected 0 arguments but got 1.

0 commit comments

Comments
 (0)