checker: do not allow module aliases started with '_' (underscore) (#9588)
parent
84fa1ae444
commit
ddb2e72301
|
@ -3977,6 +3977,7 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
|
|||
}
|
||||
|
||||
fn (mut c Checker) import_stmt(imp ast.Import) {
|
||||
c.check_valid_snake_case(imp.alias, 'module alias', imp.pos)
|
||||
for sym in imp.syms {
|
||||
name := '${imp.mod}.$sym.name'
|
||||
if sym.name[0].is_capital() {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/modules/module_alias_started_with_underscore/main.v:3:1: error: module alias `_` cannot start with `_`
|
||||
1 | module main
|
||||
2 |
|
||||
3 | import underscore as _
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~
|
||||
4 |
|
||||
5 | fn main() {
|
|
@ -0,0 +1,7 @@
|
|||
module main
|
||||
|
||||
import underscore as _
|
||||
|
||||
fn main() {
|
||||
_.foo()
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
module underscore
|
||||
|
||||
pub fn foo() {
|
||||
println('bar')
|
||||
}
|
Loading…
Reference in New Issue