Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 25, 2012 [Issue 8892] New: Not precise error message with failed fixed size array assign | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8892 Summary: Not precise error message with failed fixed size array assign Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2012-10-25 09:57:53 PDT --- struct Foo { char[3] data; } int bar(Foo f) { return f.data[0]; } void main() { auto f = Foo(['A', 'B']); } DMD 2.061alpha: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char A better error message is: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char[4] Or even something like: test.d(8): Error: cannot implicitly convert expression (['A','B']) of type char[] to char[4] ('Foo.data' field) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8892] Not precise error message with failed fixed size array assign | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-25 10:47:34 PDT --- (In reply to comment #0) > A better error message is: > > test.d(8): Error: cannot implicitly convert expression (['A','B']) of type > char[] to char[4] Don't you mean char[3]? Also the 'bar' function is not necessary for test-case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 25, 2012 [Issue 8892] Not precise error message with failed fixed size array assign | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #2 from bearophile_hugs@eml.cc 2012-10-25 11:14:47 PDT --- (In reply to comment #1) > Don't you mean char[3]? Right, sorry (this code comes from Issue 8893 ). > Also the 'bar' function is not necessary for test-case. Right, shorter test case: struct Foo { char[2] data; } void main() { auto f = Foo(['A']); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 29, 2012 [Issue 8892] Not precise error message with failed fixed size array assign | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-11-29 14:49:23 PST --- *** Issue 8918 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 26, 2013 [Issue 8892] Not precise error message with failed fixed size array assign | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-26 14:35:20 PST --- (In reply to comment #2) > struct Foo { > char[2] data; > } > void main() { > auto f = Foo(['A']); > } What I don't understand is why the above fails at compile-time but the following compiles (it fails at runtime): char[2] data = ['A']; $ object.Error: lengths don't match for array copy, 2 = 1 I think this case should also an accepts-invalid, because the compiler can see at compile-time that the lengths don't match. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 26, 2013 [Issue 8892] Wrong diagnostic for static array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Platform|x86 |All AssignedTo|nobody@puremagic.com |andrej.mitrovich@gmail.com Summary|Not precise error message |Wrong diagnostic for static |with failed fixed size |array assignment |array assign | OS/Version|Windows |All Severity|minor |normal --- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-26 14:44:44 PST --- https://github.com/D-Programming-Language/dmd/pull/1558 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 27, 2013 [Issue 8892] Wrong diagnostic for static array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-27 01:16:38 PST --- (In reply to comment #4) > What I don't understand is why the above fails at compile-time but the following compiles (it fails at runtime): > > char[2] data = ['A']; > > $ object.Error: lengths don't match for array copy, 2 = 1 > > I think this case should also an accepts-invalid, because the compiler can see at compile-time that the lengths don't match. It is known inconsistency around static array initialization. int[3] garr = [1,2]; // When creating data section, garr[2] is filled by 0 void main() { int[3] larr = [1,2]; // This is translated to runtime element-wise blit assign: // larr[0..3] = [1,2] // and fails at runtime. } When we based on the issue, following code still have similar issue. struct Foo { char[2] data; } void main() { auto f = Foo(['A']); // 1. should be compile time error, array length mismatch, or // 2. the initializer should be translated to Foo(['A', char.init]) ? } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 27, 2013 [Issue 8892] Wrong diagnostic for static array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #7 from github-bugzilla@puremagic.com 2013-01-27 01:32:19 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/646ce34fae3a1e12032bb7a2343e54daf0074db0 Fixes Issue 8892 - Better diagnostic for static array assignment. https://github.com/D-Programming-Language/dmd/commit/c316e2e6d059b7e6fdc6ae8616e72dfda9dfa8f6 Merge pull request #1558 from AndrejMitrovic/Fix8892 Issue 8892 - Better diagnostic for static array assignment -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 27, 2013 [Issue 8892] Wrong diagnostic for static array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-27 07:01:24 PST --- Error message is now improved. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 11, 2013 [Issue 8892] Wrong diagnostic for static array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8892 --- Comment #9 from github-bugzilla@puremagic.com 2013-02-11 12:20:20 PST --- Commits pushed to staging at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/646ce34fae3a1e12032bb7a2343e54daf0074db0 Fixes Issue 8892 - Better diagnostic for static array assignment. https://github.com/D-Programming-Language/dmd/commit/c316e2e6d059b7e6fdc6ae8616e72dfda9dfa8f6 Merge pull request #1558 from AndrejMitrovic/Fix8892 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation