groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Kowalczyk <kowalczyk.krzysz...@gmail.com>
Subject Bug in macro variable substitution, 2.5.0 beta 2 ?
Date Wed, 15 Nov 2017 00:00:46 GMT
Hi, 

It seems that variable substitution does not work inside of closures in
macro block. I.e:

def var = GeneralUtils.varX("foo")
def x = macro {
    $v{var}.takesClosure { $v{var} }
} 

generate AST more or less like that:

methodCall {
    variable("foo") // correct substitution
    constant "takesClosure"
    argumentList {
        closure {
            parameters{}
            block {
                expression {
                    methodCall {
                        variable("this")
                        constant('$v') // no substitution
                        argumentList {
                            closure { // literal handing of {var}
                                parameters {}
                                block {
                                    expression {
                                        variable("var")
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

So if $v is inside another closure it will not be replaced. 

Regards,
Krzysztof



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Mime
View raw message