From 581bcfe29094f525d2ab4e27455bed18a3eac811 Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Wed, 18 Nov 2020 15:56:31 +0800 Subject: [PATCH] fix #6497 (#16027) * fix #6497 * add testcase for #16027 --- compiler/ast.nim | 1 + tests/ccgbugs/t16027.nim | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/ccgbugs/t16027.nim diff --git a/compiler/ast.nim b/compiler/ast.nim index 3d14aba66f..c75a149c02 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1441,6 +1441,7 @@ proc copySym*(s: PSym; id: ItemId): PSym = result.position = s.position result.loc = s.loc result.annex = s.annex # BUGFIX + result.constraint = s.constraint if result.kind in {skVar, skLet, skField}: result.guard = s.guard result.bitsize = s.bitsize diff --git a/tests/ccgbugs/t16027.nim b/tests/ccgbugs/t16027.nim new file mode 100644 index 0000000000..58f15eb6e3 --- /dev/null +++ b/tests/ccgbugs/t16027.nim @@ -0,0 +1,13 @@ +discard """ + ccodecheck: "__restrict__" + action: compile + joinable: false +""" + +# see bug #16027 +iterator myitems(s: seq[int]): int = + var data {.codegenDecl: "$# __restrict__ $#".} : ptr int = nil + yield 1 + +for i in @[1].myitems: + discard