[Issue 3854] Error on static initialization of arrays with trailing comma.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 1 17:43:09 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3854



--- Comment #5 from Iain Buclaw <ibuclaw at ubuntu.com> 2010-04-01 17:43:06 PDT ---
Created an attachment (id=597)
keep track of static array initiliasiser depth

OK, just for clarification.

uint[][] b = [[ 1, 2 ]];   // OK
uint[][] b = [[ 1, 2 ],];  // OK
uint[][] b = [[ 1, 2, ],]; // OK
uint[][] b = [[ 1, 2, ]];  // Error

Why this happens?
The scan ahead loop in parse.c isn't aware of just how deep it has navigated
into the array it is scanning.

First loop, scans the string:
"[[ 1, 2, ]]"
Second loop, because of the trailing comma, starts another parseInitializer()
call, but this time scanning the string:
"[ 1, 2, ]]"

Because it reaches end of the scan ahead loop earlier this time, and checking
the next token fails, then treats it as an expression, not an array
initializer.

Attached is a patch that resolves the issue. Am not sure that the patch in the
other bug report is reasonably correct, but hey ho!

Regards
Iain

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list