diff options
author | metagn <metagngn@gmail.com> | 2023-05-05 08:28:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-05 07:28:06 +0200 |
commit | e92d7681bbdff1fbd28b50aa4c40270b13c48ca1 (patch) | |
tree | 5b42c39dbd62e09302c77d7ba965faf2fa2559f2 /tests/generics/tbaddeprecated.nim | |
parent | 62f1ad54aef29979f595b0438ae821a23151e1cf (diff) | |
download | Nim-e92d7681bbdff1fbd28b50aa4c40270b13c48ca1.tar.gz |
consistent use of scForceOpen for generic dot field symbols (#21738)
* always force open generic dot field symbols? fixes #21724 but might break code * alternative, should fix CI * other alternative, add test for previous CI failure * not needed * make sure call doesn't compile too * ok actual second test * ok final actual correct test * apply performance idea * don't make fromDotExpr static
Diffstat (limited to 'tests/generics/tbaddeprecated.nim')
-rw-r--r-- | tests/generics/tbaddeprecated.nim | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/generics/tbaddeprecated.nim b/tests/generics/tbaddeprecated.nim new file mode 100644 index 000000000..335234a25 --- /dev/null +++ b/tests/generics/tbaddeprecated.nim @@ -0,0 +1,55 @@ +discard """ + output: ''' +not deprecated +not deprecated +not error +not error +''' +""" + +# issue #21724 + +block: # deprecated + {.push warningAsError[Deprecated]: on.} + type + SomeObj = object + hey: bool + proc hey() {.deprecated: "Shouldn't use this".} = echo "hey" + proc gen(o: auto) = + doAssert not compiles(o.hey()) + if o.hey: + echo "not deprecated" + gen(SomeObj(hey: true)) + doAssert not (compiles do: + proc hey(o: SomeObj) {.deprecated: "Shouldn't use this".} = echo "hey" + proc gen2(o: auto) = + if o.hey(): + echo "not deprecated" + gen2(SomeObj(hey: true))) + proc hey(o: SomeObj) {.deprecated: "Shouldn't use this".} = echo "hey" + proc gen3(o: auto) = + if o.hey: + echo "not deprecated" + gen3(SomeObj(hey: true)) + {.pop.} +block: # error + type + SomeObj = object + hey: bool + proc hey() {.error: "Shouldn't use this".} = echo "hey" + proc gen(o: auto) = + doAssert not compiles(o.hey()) + if o.hey: + echo "not error" + gen(SomeObj(hey: true)) + doAssert not (compiles do: + proc hey(o: SomeObj) {.error: "Shouldn't use this".} = echo "hey" + proc gen2(o: auto) = + if o.hey(): + echo "not error" + gen2(SomeObj(hey: true))) + proc hey(o: SomeObj) {.error: "Shouldn't use this".} = echo "hey" + proc gen3(o: auto) = + if o.hey: + echo "not error" + gen3(SomeObj(hey: true)) |