diff --git a/tests/specialops/terrmsgs.nim b/tests/specialops/terrmsgs.nim index 3027faa5b336..6f2864a6fe31 100644 --- a/tests/specialops/terrmsgs.nim +++ b/tests/specialops/terrmsgs.nim @@ -54,3 +54,23 @@ block: # non-routine type shows `()` overloads: b(123) #[tt.Error ^ type mismatch: got ]# + +# issue #7777 + +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`) #[tt.Error + ^ undeclared field: 'getField' for type terrmsgs.TestType [type declared in terrmsgs.nim(63, 8)]# + + var tt: TestType + discard tt.field