[Issue 977] Expressions inside a struct or array initializer get wrong line number
https://issues.dlang.org/show_bug.cgi?id=977 Andrei Alexandrescu changed: What|Removed |Added Version|D1 & D2 |D2 --
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 --- Comment #7 from github-bugzi...@puremagic.com 2012-03-07 21:17:45 PST --- Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6f9e42c84fc1d4fdd91d2387fe5bbdf549e8b018 fix Issue 977 - Expressions inside a struct or array initializer get wrong line number -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 Walter Bright changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 --- Comment #6 from github-bugzi...@puremagic.com 2012-03-07 19:27:09 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/dc8b6ea10b4e76cddc0e13119443e286cff6ba6c Merge pull request #790 from p0nce/master Bug 977 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 ponce changed: What|Removed |Added CC||alil...@gmail.com --- Comment #5 from ponce 2012-03-05 17:03:12 PST --- My patch proposal: https://github.com/p0nce/dmd/commit/bedcd6e7dc43087afdf816cf00debba03aafd400 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 --- Comment #4 from yebblies 2012-02-03 12:47:13 EST --- (In reply to comment #3) > (In reply to comment #2) > > This happens because the parser scans across the whole initializer to > > determine > > if it's an expression or an initializer. Because it's already lexed the > > whole > > initializer, the lexer's loc points to the end, and this is what is > > assigned to > > each expression. Not sure how to solve this without re-lexing the > > initializer. > > But it manages to give line numbers for errors that occur in the semantic > analysis phase. The D compiler first lexes/parses the entire source file, > then > semantically analyses it. So it should be able to get this right. > It lexes while it parses, so when the parser creates the ast it can use the current location of the lexer instead of storing in the tokens. This is very efficient and works everywhere except when arbitrary lookahead is required. > Two ways I can see to do it: > - Remember the line number of every token just in case As a last resort. This would likely be a performance hit, and complicate the parser code in most places for no benefit. > - Realise on hitting the 7 that it is no longer parseable as either an > expression or an initialiser, and deliver the error there and then. It would have to be parsing to find this error, while it scans it's only lexing. The relevant code is at 3185 and 3272 in parse.c The solution is probably to initially parse it one way and convert if wrong, preserving location information, but this might not be possible. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 Stewart Gordon changed: What|Removed |Added CC||s...@iname.com --- Comment #3 from Stewart Gordon 2012-02-02 12:04:33 PST --- (In reply to comment #2) > This happens because the parser scans across the whole initializer to > determine > if it's an expression or an initializer. Because it's already lexed the whole > initializer, the lexer's loc points to the end, and this is what is assigned > to > each expression. Not sure how to solve this without re-lexing the > initializer. But it manages to give line numbers for errors that occur in the semantic analysis phase. The D compiler first lexes/parses the entire source file, then semantically analyses it. So it should be able to get this right. Two ways I can see to do it: - Remember the line number of every token just in case - Realise on hitting the 7 that it is no longer parseable as either an expression or an initialiser, and deliver the error there and then. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 977] Expressions inside a struct or array initializer get wrong line number
http://d.puremagic.com/issues/show_bug.cgi?id=977 yebblies changed: What|Removed |Added CC||yebbl...@gmail.com Platform|x86 |All Version|1.006 |D1 & D2 Summary|Wrong line number reported |Expressions inside a struct |for a missing comma in an |or array initializer get |array initializer within a |wrong line number |struct initializer | OS/Version|Windows |All Severity|minor |major --- Comment #2 from yebblies 2012-02-02 14:02:38 EST --- This happens because the parser scans across the whole initializer to determine if it's an expression or an initializer. Because it's already lexed the whole initializer, the lexer's loc points to the end, and this is what is assigned to each expression. Not sure how to solve this without re-lexing the initializer. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---