diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-11-29 17:36:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-29 10:36:20 +0100 |
commit | 96513b2506d9057744da9926986181294a3da653 (patch) | |
tree | e517c18a371a395aa03887a52d035dd3187f6c87 /tests/objects/tobject_default_value.nim | |
parent | 795aad4f2a0032ed9b54a7b89dc08b420981e208 (diff) | |
download | Nim-96513b2506d9057744da9926986181294a3da653.tar.gz |
fixes #22926; Different type inferred when setting a default value for an array field (#22999)
fixes #22926
Diffstat (limited to 'tests/objects/tobject_default_value.nim')
-rw-r--r-- | tests/objects/tobject_default_value.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/objects/tobject_default_value.nim b/tests/objects/tobject_default_value.nim index 3af790da6..152b355f4 100644 --- a/tests/objects/tobject_default_value.nim +++ b/tests/objects/tobject_default_value.nim @@ -717,6 +717,33 @@ template main {.dirty.} = doAssert T().kind == B + block: # bug #22926 + type + Direction = enum + North + South + East + West + + ArrayObj1 = object + list: array[Direction, int] + + ArrayObj2 = object + list: array[Direction, int] = [1, 2, 3, 4] + + block: + var a: ArrayObj1 + doAssert a.list[West] == 0 + var b = default ArrayObj1 + doAssert b.list[North] == 0 + + + block: + var a: ArrayObj2 + doAssert a.list[West] == 0 + var b = default ArrayObj2 + doAssert b.list[North] == 1 + static: main() main() |