Files
Nim/tests/vm/tnilclosurecallstacktrace.nim
metagn f69809bb17 proper error for calling nil closure in VM (#24059)
fixes #24057

Instead of crashing the compiler, the VM now gives a stacktrace if a nil
closure is attempted to be called.
2024-09-04 09:13:04 +02:00

24 lines
462 B
Nim

discard """
action: reject
nimout: '''
stack trace: (most recent call last)
tnilclosurecallstacktrace.nim(23, 6) tnilclosurecallstacktrace
tnilclosurecallstacktrace.nim(20, 6) baz
tnilclosurecallstacktrace.nim(17, 6) bar
tnilclosurecallstacktrace.nim(14, 4) foo
tnilclosurecallstacktrace.nim(14, 4) Error: attempt to call nil closure
'''
"""
proc foo(x: proc ()) =
x()
proc bar(x: proc ()) =
foo(x)
proc baz(x: proc ()) =
bar(x)
static:
baz(nil)