mirror of
https://github.com/vlang/v.git
synced 2025-09-09 15:27:05 -04:00
ast: check receivers of callexprs too in ast.Table.dependent_names_in_expr (used for finding the constants, that another constant depends on) (#19601)
This commit is contained in:
parent
772eb1ed12
commit
79b068bd2e
@ -2342,6 +2342,9 @@ pub fn (t &Table) dependent_names_in_expr(expr Expr) []string {
|
||||
names << t.dependent_names_in_expr(expr.init_expr)
|
||||
}
|
||||
CallExpr {
|
||||
if expr.is_method {
|
||||
names << t.dependent_names_in_expr(expr.left)
|
||||
}
|
||||
for arg in expr.args {
|
||||
names << t.dependent_names_in_expr(arg.expr)
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import rand
|
||||
|
||||
const (
|
||||
@ -8,3 +9,18 @@ fn test_rand_is_initialized_before_main() {
|
||||
eprintln('random letter: ${my_random_letter_const.str()} | ASCII code: ${my_random_letter_const}')
|
||||
assert my_random_letter_const.is_capital()
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
const (
|
||||
last_constant = fn_that_calls_a_method_on_a_constant()
|
||||
a_constant = os.join_path(@VROOT, 'a')
|
||||
)
|
||||
|
||||
fn fn_that_calls_a_method_on_a_constant() string {
|
||||
return a_constant.replace('\\', '/')
|
||||
}
|
||||
|
||||
fn test_consts_initialised_with_a_function_that_uses_other_consts_as_receivers_are_properly_ordered() {
|
||||
assert last_constant != ''
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user