Propose making empty array literal illegal

31 views
Skip to first unread message

emck

unread,
Dec 16, 2011, 2:40:05 PM12/16/11
to Sedona Framework
Recently I stumbled across a shadowy corner of sedonac where it allows
the definition of an empty array literal using the syntax "{ , }".
(Interestingly, it does not allow "{ , , }" -- only the one-comma
version.)

This syntax appears in the array literal interning test in
ArrayTest.sedona, where it is used to verify that a valid two-element
array literal does not get assigned the same block index in the scode
constant pool.

When the scode constant pool is constructed, however, the empty array
is "added" with an array length of 0. Since it does not actually wite
any values to the constant pool, the block index of whatever element
comes next will be the same as the one for the empty array. The order
of the const pool elements depends on the order of their hash keys,
making it non-trivial to predict which element will match the empty
one.

Since the behavior of this construct is ill-defined, and the test that
it performs can be accomplished in other, more reliable, ways, I
propose that this syntax should be caught and rejected by sedonac at
kit compile time.

If none of this means anything to you, just nod your head sagely in
agreement. :)

If you understand what I'm describing and can suggest a valid use case
for keeping this syntax legal, please let me know. Otherwise it will
be removed for Sedona 1.2 .

Beth

Matthew

unread,
Jan 10, 2012, 8:07:33 AM1/10/12
to sedo...@googlegroups.com
Just a quick follow-up.  The resolution of this topic is as follows:

1) empty array literal syntax is now a syntax error when compiling sedona code (.sedona) to IR.
2) empty array literal syntax is still supported when compiling IR -> Scode. This allows for the compiler to still generate scode images when using kits that were compiled using the older compiler.
Reply all
Reply to author
Forward
0 new messages