mirror of
https://github.com/vlang/v.git
synced 2025-09-22 20:09:04 -04:00
checker: fix calls with result propagation, using other consts, in const declaration expressions (fix #21609) (#25060)
This commit is contained in:
parent
3b561d590d
commit
3a6b651fa4
@ -4256,9 +4256,10 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
|
||||
if typ == 0 {
|
||||
old_c_mod := c.mod
|
||||
c.mod = obj.mod
|
||||
inside_const := c.inside_const
|
||||
c.inside_const = true
|
||||
typ = c.expr(mut obj.expr)
|
||||
c.inside_const = false
|
||||
c.inside_const = inside_const
|
||||
c.mod = old_c_mod
|
||||
|
||||
if mut obj.expr is ast.CallExpr {
|
||||
|
10
vlib/v/tests/consts/const_propagate_result_test.v
Normal file
10
vlib/v/tests/consts/const_propagate_result_test.v
Normal file
@ -0,0 +1,10 @@
|
||||
const constant = 5
|
||||
const other = init_const(constant)!
|
||||
|
||||
fn test_main() {
|
||||
assert other == 5
|
||||
}
|
||||
|
||||
fn init_const(c int) !int {
|
||||
return c
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user