mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
fixes requiresInit for var statements without initialization (#24177)
ref https://forum.nim-lang.org/t/12530
This commit is contained in:
10
tests/objects/trequireinit.nim
Normal file
10
tests/objects/trequireinit.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
discard """
|
||||
errormsg: "The MPlayerObj type doesn't have a default value. The following fields must be initialized: foo."
|
||||
"""
|
||||
|
||||
type
|
||||
MPlayerObj* {.requiresInit.} = object
|
||||
foo: range[5..10] = 5
|
||||
|
||||
var a: MPlayerObj
|
||||
echo a.foo
|
||||
Reference in New Issue
Block a user