Files
Nim/tests/vm/tconstprocassignments.nim
ringabout 3c528c987c fixes #24359; VM problem: dest register is not set with const-bound proc (#24364)
fixes #24359

follow up https://github.com/nim-lang/Nim/pull/11076

It should not try to evaluate the const proc if the proc doesn't have a
return value.

(cherry picked from commit 031ad957ba)
2025-01-14 07:51:44 +01:00

34 lines
472 B
Nim

discard """
output: '''
100
100
'''
"""
proc f():int {.compileTime.} = 100
const F = f
echo F()
const G = proc ():int =
let x = f
let y = x
y()
echo G()
block: # bug #24359
block:
proc h(_: bool) = discard
const m = h
static: m(true) # works
m(true) # does not work
block:
block:
proc h(_: bool): int = result = 1
const m = h
static: doAssert m(true) == 1 # works
doAssert m(true) == 1 # does not work