-
-
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.
checker, cgen: fix the static from_string method of Enum across mods(fix
- Loading branch information
Showing
10 changed files
with
152 additions
and
22 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
40 changes: 40 additions & 0 deletions
40
vlib/v/checker/tests/modules/enum_from_string_in_different_mods.out
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,40 @@ | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:3:8: warning: module 'mod' is imported but never used | ||
1 | module main | ||
2 | | ||
3 | import mod { MyEnum, MyStruct } | ||
| ~~~ | ||
4 | | ||
5 | fn main() { | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:3:14: error: module `mod` type `MyEnum` is private | ||
1 | module main | ||
2 | | ||
3 | import mod { MyEnum, MyStruct } | ||
| ~~~~~~ | ||
4 | | ||
5 | fn main() { | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:6:7: error: module `mod` type `mod.MyEnum` is private | ||
4 | | ||
5 | fn main() { | ||
6 | _ := MyEnum.from_string('item1') | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | _ := MyStruct.from_string('item1') | ||
8 | } | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:6:4: error: assignment mismatch: 1 variable(s) but `MyEnum.from_string()` returns 0 value(s) | ||
4 | | ||
5 | fn main() { | ||
6 | _ := MyEnum.from_string('item1') | ||
| ~~ | ||
7 | _ := MyStruct.from_string('item1') | ||
8 | } | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:7:7: error: expected enum, but `mod.MyStruct` is struct | ||
5 | fn main() { | ||
6 | _ := MyEnum.from_string('item1') | ||
7 | _ := MyStruct.from_string('item1') | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | } | ||
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v:7:4: error: assignment mismatch: 1 variable(s) but `MyStruct.from_string()` returns 0 value(s) | ||
5 | fn main() { | ||
6 | _ := MyEnum.from_string('item1') | ||
7 | _ := MyStruct.from_string('item1') | ||
| ~~ | ||
8 | } |
8 changes: 8 additions & 0 deletions
8
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/main.v
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 @@ | ||
module main | ||
|
||
import mod { MyEnum, MyStruct } | ||
|
||
fn main() { | ||
_ := MyEnum.from_string('item1') | ||
_ := MyStruct.from_string('item1') | ||
} |
8 changes: 8 additions & 0 deletions
8
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/src/mod.v
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 @@ | ||
module mod | ||
|
||
enum MyEnum { | ||
item1 | ||
item2 | ||
} | ||
|
||
pub struct MyStruct {} |
1 change: 1 addition & 0 deletions
1
vlib/v/checker/tests/modules/enum_from_string_in_different_mods/v.mod
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 @@ | ||
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
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
10 changes: 10 additions & 0 deletions
10
vlib/v/tests/modules/enum_from_string_in_different_mods/src/main_test.v
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,10 @@ | ||
module main | ||
|
||
import mod { MyEnum } | ||
|
||
fn test_main() { | ||
item1 := MyEnum.from_string('item1')? | ||
assert item1 == MyEnum.item1 | ||
item2 := mod.MyEnum.from_string('item2')? | ||
assert item2 == MyEnum.item2 | ||
} |
6 changes: 6 additions & 0 deletions
6
vlib/v/tests/modules/enum_from_string_in_different_mods/src/mod/mod.v
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 @@ | ||
module mod | ||
|
||
pub enum MyEnum { | ||
item1 | ||
item2 | ||
} |
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 @@ | ||
1 |