Maybe I am missing something, but here's a simple example.
Example 1 ============
pegjs:
start
= expr
expr
= { return {item: 'asd'}; }
--------
Output:
[]
Example 2 ============
pegjs:
start
= expr
expr
= { return {item: 0}; }
--------
Output:
{
"item": 0
}
Example 3 ============
pegjs:
start
= expr
expr
= { return {item: 123}; }
--------
Output:
[]
=====================
Only example 2 illustrates the behavour I expect. What's wrong with the others?
Any suggestions please?
Funnily enough, if you try to use another property name, it works:
Example 1 ============
pegjs:
start
= expr
expr
= { return {index: 123}; }
--------
Output:
{
"index": 123
}
=====================
Looks like the property name 'item' is reserved by PEGjs for some processing behind the scenes. Still, I would like an explanation. If I'm right, this should be documented.