-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into branch_prediction_2
- Loading branch information
Showing
25 changed files
with
303 additions
and
38 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
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,12 @@ | ||
vlib/v/checker/or_block_assert_err.vv:10:22: error: last statement in the `or {}` block should be an expression of type `int` or exit parent scope | ||
8 | | ||
9 | f() or { assert true } | ||
10 | a := f() or { assert true } | ||
| ~~~~~~ | ||
11 | dump(a) | ||
12 | g(f() or { assert true }) | ||
vlib/v/checker/or_block_assert_err.vv:12:19: error: last statement in the `or {}` block should be an expression of type `int` or exit parent scope | ||
10 | a := f() or { assert true } | ||
11 | dump(a) | ||
12 | g(f() or { assert true }) | ||
| ~~~~~~ |
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 @@ | ||
fn g(x int) { | ||
dump(x) | ||
} | ||
|
||
fn f() ?int { | ||
return none | ||
} | ||
|
||
f() or { assert true } | ||
a := f() or { assert true } | ||
dump(a) | ||
g(f() or { assert true }) |
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,56 @@ | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:9:2: warning: unused variable: `a` | ||
7 | | ||
8 | fn main() { | ||
9 | a := foo() or { foo() or {} } | ||
| ^ | ||
10 | | ||
11 | // must be error | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:12:2: warning: unused variable: `y` | ||
10 | | ||
11 | // must be error | ||
12 | y := if c := foo() { | ||
| ^ | ||
13 | dump(c) | ||
14 | bar() or {} | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:20:2: warning: unused variable: `z` | ||
18 | | ||
19 | // ok | ||
20 | z := if d := foo() { | ||
| ^ | ||
21 | dump(d) | ||
22 | bar() or {} | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:29:2: warning: unused variable: `w` | ||
27 | | ||
28 | // ok | ||
29 | w := foo() or { | ||
| ^ | ||
30 | bar() or {} | ||
31 | false | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:35:2: warning: unused variable: `b` | ||
33 | | ||
34 | // ok | ||
35 | b := foo() or { | ||
| ^ | ||
36 | foo() or {} | ||
37 | false | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:9:24: error: expression requires a non empty `or {}` block | ||
7 | | ||
8 | fn main() { | ||
9 | a := foo() or { foo() or {} } | ||
| ~~~~~ | ||
10 | | ||
11 | // must be error | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:14:9: error: expression requires a non empty `or {}` block | ||
12 | y := if c := foo() { | ||
13 | dump(c) | ||
14 | bar() or {} | ||
| ~~~~~ | ||
15 | } else { | ||
16 | false | ||
vlib/v/checker/tests/call_empty_or_block_err.vv:14:3: error: the final expression in `if` or `match`, must have a value of a non-void type | ||
12 | y := if c := foo() { | ||
13 | dump(c) | ||
14 | bar() or {} | ||
| ~~~~~ | ||
15 | } else { | ||
16 | false |
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,39 @@ | ||
fn foo() !bool { | ||
return true | ||
} | ||
|
||
fn bar() ! { | ||
} | ||
|
||
fn main() { | ||
a := foo() or { foo() or {} } | ||
|
||
// must be error | ||
y := if c := foo() { | ||
dump(c) | ||
bar() or {} | ||
} else { | ||
false | ||
} | ||
|
||
// ok | ||
z := if d := foo() { | ||
dump(d) | ||
bar() or {} | ||
true | ||
} else { | ||
false | ||
} | ||
|
||
// ok | ||
w := foo() or { | ||
bar() or {} | ||
false | ||
} | ||
|
||
// ok | ||
b := foo() or { | ||
foo() or {} | ||
false | ||
} | ||
} |
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,6 @@ | ||
vlib/v/checker/tests/fn_call_or_block_err.vv:7:18: error: wrong return type `int literal` in the `or {}` block, expected `string` | ||
5 | } | ||
6 | | ||
7 | y := Aa(f() or { 2 }) | ||
| ^ | ||
8 | println(y) |
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 @@ | ||
type Aa = string | int | ||
|
||
fn f() !string { | ||
return '' | ||
} | ||
|
||
y := Aa(f() or { 2 }) | ||
println(y) |
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,14 @@ | ||
vlib/v/checker/tests/lambda_or_block_err.vv:10:10: error: cannot use `!int` as type `int` in return argument | ||
8 | | ||
9 | fn main() { | ||
10 | foo(|i| bar(i)) | ||
| ~~~~~~ | ||
11 | foo(|i| bar(i) or {}) | ||
12 | foo(|i| bar(i) or { 0 }) | ||
vlib/v/checker/tests/lambda_or_block_err.vv:11:17: error: expression requires a non empty `or {}` block | ||
9 | fn main() { | ||
10 | foo(|i| bar(i)) | ||
11 | foo(|i| bar(i) or {}) | ||
| ~~~~~ | ||
12 | foo(|i| bar(i) or { 0 }) | ||
13 | } |
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 @@ | ||
fn foo(callback fn (int) int) { | ||
dump([1, 2, 3].map(callback)) | ||
} | ||
|
||
fn bar(a int) !int { | ||
return a | ||
} | ||
|
||
fn main() { | ||
foo(|i| bar(i)) | ||
foo(|i| bar(i) or {}) | ||
foo(|i| bar(i) or { 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
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
Oops, something went wrong.