diff options
author | Bung <crc32@qq.com> | 2023-01-13 06:36:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 15:36:13 +0100 |
commit | 5f41be3b4503a76fb68018c3ff5b05b35d6d68c1 (patch) | |
tree | fa89c4ce02a3911924d8a060eacffa086d4c25e6 | |
parent | 1e52423774e81f71d10a712575fd65231705362e (diff) | |
download | Nim-5f41be3b4503a76fb68018c3ff5b05b35d6d68c1.tar.gz |
fix #20253 (#21174)
* fix #20253 * change NimbleStableCommit * Update koch.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
-rw-r--r-- | compiler/sempass2.nim | 5 | ||||
-rw-r--r-- | tests/misc/t20253.nim | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index f13d8d8d4..747540c78 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -1488,7 +1488,10 @@ proc trackProc*(c: PContext; s: PSym, body: PNode) = s.kind in {skProc, skFunc, skConverter, skMethod} and s.magic == mNone: var res = s.ast[resultPos].sym # get result symbol if res.id notin t.init: - message(g.config, body.info, warnProveInit, "result") + if tfRequiresInit in s.typ[0].flags: + localError(g.config, body.info, "'$1' requires explicit initialization" % "result") + else: + message(g.config, body.info, warnProveInit, "result") let p = s.ast[pragmasPos] let raisesSpec = effectSpec(p, wRaises) if not isNil(raisesSpec): diff --git a/tests/misc/t20253.nim b/tests/misc/t20253.nim new file mode 100644 index 000000000..d47c36c55 --- /dev/null +++ b/tests/misc/t20253.nim @@ -0,0 +1,10 @@ +discard """ + errormsg: "'result' requires explicit initialization" + line: 10 +""" + +type Meow {.requiresInit.} = object + init: bool + +proc initMeow(): Meow = + discard |