Hmm, I think the macro gets confused somewhere along the line when you are
trying to use **field1** as the name for a local variable and the name of the
field in your **B** object.
The macro would be working, however, the compiler notices that something is
wrong and infers incorrectly the type of the **f.field1** statement to be
**untyped** and therefore fails to even hit the macro expansion because
**echo** doesn't know how to print an **untyped** type.
To fix it, you can do this:
import macros
type
B = object of RootObj
field1: int
type
A[T] = object
inner: T
macro `.`*(obj: A, v): untyped =
echo "running macro"
newDotExpr(newDotExpr(obj, newIdentNode("inner")), newIdentNode(v.strVal))
proc t1*() =
var f: A[B]
f.inner.field1 = 777 # If you don't have a local variable named field1,
then the code works as you expect
echo f.field1
t1()
But maybe it would help to understand why you were trying to use a local
variable for **field1**.