-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some negative tests for labelled args
- Loading branch information
1 parent
2564e63
commit 5936746
Showing
9 changed files
with
1,363 additions
and
1,303 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// fail: Duplicate argument for parameter `b` | ||
|
||
|
||
def foo(a: u32, b: u32 = 4, c: u32 = 5): u32 => a + b + c | ||
|
||
def main() { | ||
foo(1, 2, b: 7) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// fail: Expected positional argument `a`, but got label `c` | ||
|
||
|
||
def foo(a: u32, b: u32, c: u32 = 5): u32 => a + b + c | ||
|
||
def main() { | ||
foo(c: 7) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// fail: Missing required argument `b` of type i32 | ||
|
||
def foo(a: i32, b: i32): i32 { | ||
return a + b | ||
} | ||
|
||
def main() { | ||
foo(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// fail: Can't have positional arguments after labelled arguments | ||
|
||
|
||
def foo(a: u32, b: u32 = 4, c: u32 = 5): u32 => a + b + c | ||
|
||
def main() { | ||
foo(1, c: 8, 7) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// fail: Unknown labelled argument `foo` | ||
|
||
|
||
def foo(a: u32, b: u32 = 4, c: u32 = 5): u32 => a + b + c | ||
|
||
def main() { | ||
foo(1, c: 8, foo: 7) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// fail: Cannot have variadic parameters and default parameters | ||
|
||
def foo(a: i32, b: i32 = 5, ...): i32 => 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// fail: Cannot use a labelled argument for a non-labeled parameter | ||
|
||
enum Foo { | ||
Case0(u32) | ||
Case1(str, i32) | ||
Case2(str) | ||
Case3 | ||
} | ||
|
||
def main() { | ||
let foo: Foo = Case0(foo: 5) | ||
} |