We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3b561d5 commit 3a6b651Copy full SHA for 3a6b651
2 files changed
vlib/v/checker/checker.v
@@ -4256,9 +4256,10 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
4256
if typ == 0 {
4257
old_c_mod := c.mod
4258
c.mod = obj.mod
4259
+ inside_const := c.inside_const
4260
c.inside_const = true
4261
typ = c.expr(mut obj.expr)
- c.inside_const = false
4262
+ c.inside_const = inside_const
4263
c.mod = old_c_mod
4264
4265
if mut obj.expr is ast.CallExpr {
vlib/v/tests/consts/const_propagate_result_test.v
@@ -0,0 +1,10 @@
1
+const constant = 5
2
+const other = init_const(constant)!
3
+
4
+fn test_main() {
5
+ assert other == 5
6
+}
7
8
+fn init_const(c int) !int {
9
+ return c
10
0 commit comments