mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 19:22:40 +00:00
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)
34 lines
472 B
Nim
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
|