1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- discard """
- action: reject
- cmd: '''nim check $options $file'''
- matrix: "; -d:testWithout; --mm:refc"
- """
- when not defined(testWithout):
- {.experimental: "dotOperators".}
- {.experimental: "callOperator".}
- block:
- type Foo = object
- type Bar = object
- x1: int
- var b: Bar
- block:
- template `.`(a: Foo, b: untyped): untyped = 123
- echo b.x
- ^ undeclared field: 'x' for type terrmsgs.Bar [type declared in terrmsgs.nim(15, 8)]]
- block:
- template `.()`(a: Foo, b: untyped): untyped = 123
- echo b.x()
- ^ attempting to call undeclared routine: 'x']
- block:
- template `.=`(a: Foo, b: untyped, c: untyped) = b = c
- b.x = 123
- ^ undeclared field: 'x=' for type terrmsgs.Bar [type declared in terrmsgs.nim(15, 8)]]
-
- block:
- template `()`(a: Foo, b: untyped, c: untyped) = echo "something"
-
- xyz(123)
- ^ undeclared identifier: 'xyz']
-
- min(123)
- ^ type mismatch: got <int literal(123)>]
-
- b(123)
- ^ attempting to call routine: 'b']
- echo b.x
- ^ undeclared field: 'x' for type terrmsgs.Bar [type declared in terrmsgs.nim(15, 8)]]
- echo b.x()
- ^ attempting to call undeclared routine: 'x']
- import macros
- block:
- type TestType = object
- private_field: string
- when false:
- template getField(obj, field: untyped): untyped = obj.field
- macro `.`(obj: TestType, field: untyped): untyped =
- let private = newIdentNode("private_" & $field)
- result = quote do:
- `obj`.getField(`private`)
- ^ attempting to call undeclared routine: 'getField']
- var tt: TestType
- discard tt.field
- block:
- proc `()`(a:string, b:string):string = a & b
- proc mewSeq[T](a,b:int)=discard
- proc mewSeq[T](c:int)= discard
- mewSeq[int]()
- ^ type mismatch: got <>]
|