checker: fix `function x is private` error in main, for `pub const abc = x()` in a (sub)module
parent
674f99a658
commit
caac89d6ca
|
@ -3818,9 +3818,13 @@ pub fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
|
|||
}
|
||||
mut typ := obj.typ
|
||||
if typ == 0 {
|
||||
old_c_mod := c.mod
|
||||
c.mod = obj.mod
|
||||
c.inside_const = true
|
||||
typ = c.expr(obj.expr)
|
||||
c.inside_const = false
|
||||
c.mod = old_c_mod
|
||||
|
||||
if obj.expr is ast.CallExpr {
|
||||
if obj.expr.or_block.kind != .absent {
|
||||
typ = typ.clear_flag(.optional)
|
||||
|
|
|
@ -4,6 +4,11 @@ fn test_mod1_can_still_be_found_through_parent_project_vmod() {
|
|||
assert 1051 == m.f()
|
||||
}
|
||||
|
||||
fn test_pub_const_using_private_fn_for_its_initialisation() {
|
||||
println(m.my_version)
|
||||
assert m.my_version == '0.0.1'
|
||||
}
|
||||
|
||||
/*
|
||||
NB: this main program is under bin/ , but it still
|
||||
can find mod1, because the parent project has v.mod,
|
||||
|
|
|
@ -13,3 +13,9 @@ import v.tests.project_with_modules_having_submodules.mod1.mod14
|
|||
pub fn f() int {
|
||||
return 1000 + mod11.f() + mod12.f() + mod13.f() + mod14.f()
|
||||
}
|
||||
|
||||
pub const my_version = get_version()
|
||||
|
||||
fn get_version() string {
|
||||
return '0.0.1'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue