Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 06, 2014 [Issue 12306] New: Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=12306 Summary: Struct Enums cannot be read at compile time Product: D Version: D2 Platform: All OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: jbinero@gmail.com --- Comment #0 from Jeroen Bollen <jbinero@gmail.com> 2014-03-06 13:50:45 PST --- Created an attachment (id=1337) Example Code - "dmd main.d" When a struct enum is defined like this, it's values cannot be read at compile time. enum Point3D point = {x:1, y:1, z:1}; int testArray[point.x][point.y][point.z]; // z Cannot be read at compile time (will error 6 times) Working (well, technically not working) code in attachment. Tested for both 32 bit and 64 bit on a Linux system. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 06, 2014 [Issue 12306] Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | https://d.puremagic.com/issues/show_bug.cgi?id=12306 --- Comment #1 from Jeroen Bollen <jbinero@gmail.com> 2014-03-06 13:54:39 PST --- (In reply to comment #0) > Created an attachment (id=1337) [details] > Example Code - "dmd main.d" > > When a struct enum is defined like this, it's values cannot be read at compile > time. > enum Point3D point = {x:1, y:1, z:1}; > int testArray[point.x][point.y][point.z]; // z Cannot be read at > compile time (will error 6 times) > > Working (well, technically not working) code in attachment. Tested for both 32 bit and 64 bit on a Linux system. Probably not important, but it errors 5 times and not 6. With adding and removing to the code I have found inconsistency in how many times it errors, and what variable it picks though. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 06, 2014 [Issue 12306] Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | https://d.puremagic.com/issues/show_bug.cgi?id=12306 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-07 01:28:20 EET --- Looks like the compiler parses the array declaration as an associative array (and conservatively assumes that "point.x" is a type), then when it realizes it is in fact a static array, it does not reparse the whole "point.x" expression correctly (it just looks at the last symbol, x). Making it clear that it is an expression, e.g. adding "+0", also fixes compilation. Fixing this is not trivial as the expression that the compiler sees in the array index is not saved. I think the correct fix would be to switch the parsing order: Assume that the array "index" is an expression, then, if it resolves to a type, reinterpret the whole thing as an associative array. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 14, 2014 [Issue 12306] Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | https://d.puremagic.com/issues/show_bug.cgi?id=12306 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull, rejects-valid --- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-13 19:59:42 PDT --- https://github.com/D-Programming-Language/dmd/pull/3379 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 14, 2014 [Issue 12306] Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | https://d.puremagic.com/issues/show_bug.cgi?id=12306 --- Comment #4 from github-bugzilla@puremagic.com 2014-03-14 07:19:02 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d6de735b9ac60e85b4fdd844f838fa5fb2bc0881 fix Issue 12306 - Struct Enums cannot be read at compile time https://github.com/D-Programming-Language/dmd/commit/0edabb313e4170a62693b4e0f1f5336a5f000c86 Merge pull request #3379 from 9rnsr/fix12306 Issue 12306 - Struct Enums cannot be read at compile time -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 14, 2014 [Issue 12306] Struct Enums cannot be read at compile time | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeroen Bollen | https://d.puremagic.com/issues/show_bug.cgi?id=12306 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |FIXED -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation