Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgen: fix alias to option handling (#18490)
- Loading branch information
Showing
4 changed files
with
116 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
vlib/v/checker/tests/alias_to_option_err.vv:11:7: error: alias to Option type requires to be used as Option type (?TestInt(...)) | ||
9 | | ||
10 | fn main() { | ||
11 | f := TestInt(1) | ||
| ~~~~~~~~~~ | ||
12 | dump(f) | ||
13 | println(f) | ||
vlib/v/checker/tests/alias_to_option_err.vv:15:7: error: alias to Option type requires to be used as Option type (?TestString(...)) | ||
13 | println(f) | ||
14 | | ||
15 | g := TestString('foo') | ||
| ~~~~~~~~~~~~~~~~~ | ||
16 | dump(g) | ||
17 | println(g) | ||
vlib/v/checker/tests/alias_to_option_err.vv:19:7: error: alias to Option type requires to be used as Option type (?TestString(...)) | ||
17 | println(g) | ||
18 | | ||
19 | h := TestString(none) | ||
| ~~~~~~~~~~~~~~~~ | ||
20 | dump(h) | ||
21 | | ||
vlib/v/checker/tests/alias_to_option_err.vv:22:7: error: alias to Option type requires to be used as Option type (?TestF64(...)) | ||
20 | dump(h) | ||
21 | | ||
22 | i := TestF64(none) | ||
| ~~~~~~~~~~~~~ | ||
23 | dump(i) | ||
24 | | ||
vlib/v/checker/tests/alias_to_option_err.vv:25:7: error: alias to Option type requires to be used as Option type (?TestStruct(...)) | ||
23 | dump(i) | ||
24 | | ||
25 | l := TestStruct(none) | ||
| ~~~~~~~~~~~~~~~~ | ||
26 | dump(l) | ||
27 | | ||
vlib/v/checker/tests/alias_to_option_err.vv:28:7: error: alias to Option type requires to be used as Option type (?TestStruct(...)) | ||
26 | dump(l) | ||
27 | | ||
28 | k := TestStruct(Struct{}) | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
29 | dump(k) | ||
30 | } |
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,30 @@ | ||
type TestInt = ?int | ||
type TestString = ?string | ||
type TestF64 = ?f64 | ||
|
||
struct Struct { | ||
} | ||
|
||
type TestStruct = ?Struct | ||
|
||
fn main() { | ||
f := TestInt(1) | ||
dump(f) | ||
println(f) | ||
|
||
g := TestString('foo') | ||
dump(g) | ||
println(g) | ||
|
||
h := TestString(none) | ||
dump(h) | ||
|
||
i := TestF64(none) | ||
dump(i) | ||
|
||
l := TestStruct(none) | ||
dump(l) | ||
|
||
k := TestStruct(Struct{}) | ||
dump(k) | ||
} |
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