[Omake] error when defining a rule inside of a function
Aleksey Nogin
nogin at metaprl.org
Mon Jan 15 09:50:02 PST 2007
On 13.01.2007 12:06, Erick Tryzelaar wrote:
> Erick Tryzelaar wrote:
>> Hmm, this led me to a stack overflow, with this OMakefile:
>
> Here's a smaller file that still has the Stack_overflow:
>
> OMakefile:
> comflags(sources) =
> return $(sources)
>
> make-rule(target, sources) =
> $(target):
> echo $(comflags $(sources))
> return $(target)
>
> .DEFAULT: $(make-rule cmain, foo)
The issues are:
- The "rule" function is being applied lazily (so that it can be
overwritten later).
- A lazy application of a function causes all the arguments to be
evaluated lazily as well (IMO this is a bug, although I am not sure
whether Jason would agree - I've filed
http://bugzilla.metaprl.org/show_bug.cgi?id=628 on this one).
- Because of is, the comflags function gets called with sources set to
$`(sources) instead of "foo", which results in an infinite loop when
trying to evaluate "return $(sources)".
See the above Bugzilla URL for some additional detail. Note that in this
example, if you alpha-rename the "sources" argument variable in one of
the functions so that the two do not clash, the problem will go away.
You can also work around this by explicitly making the call to comflags
eager by either using the $,(comflags ...) syntax or by using an
intermediate variable, like you did.
Aleksey
More information about the Omake
mailing list