Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: make the
type C.X is private
re-declaration error more inf…
…ormative
- Loading branch information
Showing
8 changed files
with
45 additions
and
6 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,5 @@ | ||
vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) | ||
1 | module module_with_redeclaration | ||
| ^ | ||
2 | | ||
3 | pub const used = 1 |
8 changes: 8 additions & 0 deletions
8
vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.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 module_with_redeclaration | ||
|
||
pub const used = 1 | ||
|
||
struct C.timeval { | ||
tv_sec u64 // Seconds. | ||
tv_usec u64 // Microseconds. | ||
} |
Empty file.
14 changes: 14 additions & 0 deletions
14
vlib/v/checker/tests/private_redeclaration_of_C_timeval.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,14 @@ | ||
vlib/time/time.c.v:90:11: error: struct `C.timeval` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `time` | ||
88 | return C.GetTickCount() | ||
89 | } $else { | ||
90 | ts := C.timeval{} | ||
| ~~~~~~~~~ | ||
91 | C.gettimeofday(&ts, 0) | ||
92 | return i64(ts.tv_sec * u64(1000) + (ts.tv_usec / u64(1000))) | ||
vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv:9:10: error: struct `C.timeval` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `main` | ||
7 | dump(time.now()) // ensure `time` is used | ||
8 | // | ||
9 | ts := C.timeval{} | ||
| ~~~~~~~~~ | ||
10 | dump(ts) | ||
11 | } |
11 changes: 11 additions & 0 deletions
11
vlib/v/checker/tests/private_redeclaration_of_C_timeval.vv
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,11 @@ | ||
import module_with_redeclaration as mr | ||
import time | ||
|
||
const used = mr.used | ||
|
||
fn main() { | ||
dump(time.now()) // ensure `time` is used | ||
// | ||
ts := C.timeval{} | ||
dump(ts) | ||
} |
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