I was creating my macros and there is a bug than pops up (from my point of view) randomly:
ASSERT: enforest assumes there are tokens to work with
I'm not sure about what does this mean but I did my best to encapsulate the problem and I end with this code:
macro foo {
rule { $bar:expr ? } => { $bar }
rule { $bar:expr } => { $bar }
}
If I invoke foo
macro between parentheses and add the ?
at the end this error is thrown:
(foo test ?)
// produces ASSERT: enforest assumes there are tokens to work with
But if I remove the parentheses or the ?
it just works
foo test ?
// produces: test
(foo test)
// produces: test
You can see it failing here:
http://sweetjs.org/browser/editor.html#macro%20foo%20%7B%0A%20%20rule%20%7B%20$bar:expr%20?%20%7D%20=%3E%20%7B%20$bar%20%7D%0A%20%20rule%20%7B%20$bar:expr%20%7D%20=%3E%20%7B%20$bar%20%7D%0A%7D%0A%0A(foo%20test%20?)%0A
So please, this is driving me crazy I'm facing this error again and again. It should be related to the :expr
operator, but I can't replace it with ...
because it's so greedy and it selects everything to the last ?
it found.
I can see the line than throws this error is here. But I don't know the context.
Any help?