Description
While working on a presentation about the JS implementation, I encountered the following error when testing some of the code I'd written for the slides:
const msg = `
.local $currency = {EUR}
.input {$price :number style=currency currency=$currency}
{{Total price: {$price}}}`;
const mf = new MessageFormat(msg, 'en');
// Syntax parse error: parse-error at [the first { of '{{Total...']
After spending quite a while debugging the implementation code to determine the error here, I came to the conclusion that my parser was correct, the above is indeed a syntax error.
The problem with this message is that the leading whitespace before the first .
means that it isn't special, and all of the declaration syntax parses as a valid simple pattern, up until the {{
pattern start.
I mentioned this problem on our Slack channel, where @stasm was also unable to initially see the problem. I think if we can't see it, other developers won't either, and that this will become a significant stumbling block.
We should consider amending the ABNF to allow whitespace before the .
at the beginning of a complex message.