mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
0ac6ba9354
commit
0bafd237ee
@ -2339,6 +2339,9 @@ pub fn (t &Table) dependent_names_in_expr(expr Expr) []string {
|
||||
PrefixExpr {
|
||||
names << t.dependent_names_in_expr(expr.right)
|
||||
}
|
||||
SelectorExpr {
|
||||
names << t.dependent_names_in_expr(expr.expr)
|
||||
}
|
||||
StructInit {
|
||||
for field in expr.fields {
|
||||
names << t.dependent_names_in_expr(field.expr)
|
||||
|
@ -10,7 +10,9 @@ const (
|
||||
fn test_const_call_expr_order() {
|
||||
dump(cache_dir)
|
||||
dump(shdc)
|
||||
assert true
|
||||
assert shdc.contains(cache_dir)
|
||||
assert shdc.contains(tool_name)
|
||||
assert shdc.ends_with(shdc_exe_name)
|
||||
}
|
||||
|
||||
fn shdc_exe() string {
|
||||
|
26
vlib/v/tests/const_selector_expr_order_test.v
Normal file
26
vlib/v/tests/const_selector_expr_order_test.v
Normal file
@ -0,0 +1,26 @@
|
||||
struct Abc {
|
||||
version string
|
||||
name string
|
||||
}
|
||||
|
||||
fn abc() !Abc {
|
||||
return Abc{
|
||||
version: 'abc'
|
||||
name: 'xyz'
|
||||
}
|
||||
}
|
||||
|
||||
// Note: version depends on a field in manifest, even though it is declared before it
|
||||
pub const version = manifest.version
|
||||
|
||||
pub const manifest = abc() or { panic(err) }
|
||||
|
||||
// Note: name depends on a field in manifest too, but it is declared after it
|
||||
pub const name = manifest.name
|
||||
|
||||
fn test_order_of_const_initialisation_should_take_into_account_selector_expressions() {
|
||||
println(version)
|
||||
println(name)
|
||||
assert version == 'abc'
|
||||
assert name == 'xyz'
|
||||
}
|
Loading…
Reference in New Issue
Block a user