-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser, checker: fix option map fn type and missing check for result …
- Loading branch information
Showing
10 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
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
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,13 @@ | ||
vlib/v/checker/tests/result_param_type_err.vv:3:13: error: result type arguments are not supported | ||
1 | module main | ||
2 | | ||
3 | fn func(arg !string, val &int) ?int { | ||
| ~~~~~~~ | ||
4 | unsafe { | ||
5 | *val = 2 | ||
vlib/v/checker/tests/result_param_type_err.vv:11:7: error: result type arguments are not supported | ||
9 | | ||
10 | fn main() { | ||
11 | _ := map[string]fn (!string, &int) ?int{} | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
12 | } |
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 @@ | ||
module main | ||
|
||
fn func(arg !string, val &int) ?int { | ||
unsafe { | ||
*val = 2 | ||
} | ||
return 2 | ||
} | ||
|
||
fn main() { | ||
_ := map[string]fn (!string, &int) ?int{} | ||
} |
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
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
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,29 @@ | ||
module main | ||
|
||
fn func(arg ?string, val &int) ?int { | ||
unsafe { | ||
*val = 2 | ||
} | ||
return 2 | ||
} | ||
|
||
fn test_main() { | ||
map1 := { | ||
'json': func | ||
} | ||
assert typeof(map1['json']).name == 'fn (?string, int) ?int' | ||
|
||
number := 0 | ||
ret := map1['json']('hi', &number) | ||
assert number == ret? | ||
assert ret? == 2 | ||
|
||
mut map2 := map[string]fn (?string, &int) ?int{} | ||
map2['json'] = func | ||
assert typeof(map2['json']).name == 'fn (?string, int) ?int' | ||
|
||
number2 := 0 | ||
ret2 := map2['json']('', &number2) | ||
assert number2 == ret2? | ||
assert ret2? == 2 | ||
} |