February 04, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 --- Comment #10 from Stewart Gordon <smjg@iname.com> 2012-02-04 06:15:31 PST --- (In reply to comment #9) > It has nothing to do with appending, but the fact that for T[][] the compiler has to choose to append an empty array as a T[] or a T[][], and it does this by checking implicit conversions, which pass incorrectly. cast(T[]) [] is a T[], simple as that. So the bug is that, in this situation, for some perverted reason an implicit conversion match is chosen over an exact match. Removing the implicit conversions stops this bug from biting, but I can imagine there being other places where it might still be an issue. I'm finding it puzzling that changing a method in ArrayLiteralExp would alter the implicit conversions of a CastExpression. But if it works, so be it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 04, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 --- Comment #11 from yebblies <yebblies@gmail.com> 2012-02-05 01:29:46 EST --- (In reply to comment #10) > cast(T[]) [] is a T[], simple as that. So the bug is that, in this situation, for some perverted reason an implicit conversion match is chosen over an exact match. Removing the implicit conversions stops this bug from biting, but I can imagine there being other places where it might still be an issue. > > I'm finding it puzzling that changing a method in ArrayLiteralExp would alter the implicit conversions of a CastExpression. But if it works, so be it. Yes and no. In CatAssignExp::semantic, the compiler calls implicitConvTo on e2 (the array literal) to see if it can convert to T[][]. ArrayLiteralExp::implicitConvTo returns a match level, and unless it returns MATCHnomatch the compiler essentially rewrites the expression as (e1 ~= cast(typeof(e1))e2). All that works fine, the problem is in ArrayLiteralExp::implicitConvTo. An array literal can implicitly convert to a type if the type is an array, and each element converts to the type's element type. ArrayLiteralExp::implicitConvTo does that with something like the following (simplified): { level = assume perfect match foreach(element) if conversion match is worse than level level = this match } Which results in the assumption never being corrected if the literal has zero elements, which makes sense because an untyped empty array literal converts to anything. This breaks down if the array literal has been set an explicit type, which is what my patch fixes. The way it's all done is actually quite clever, but it takes a bit of work to understand. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 19, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 --- Comment #12 from github-bugzilla@puremagic.com 2012-07-19 00:14:06 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/82700b3d2cf466cd69f57491a759a14e101467ac Issue 2006 - Empty array literals with explicit type implicitly convert to anything ArrayLiteralExp::implicitConvTo defaults to MATCHexact, and when there are no parameters it is never corrected. https://github.com/D-Programming-Language/dmd/commit/9268d6fb1bedf9d931eadb5adf4067698b0d1e19 Merge pull request #691 from yebblies/issue2006 Issue 2006 - Empty array literals with explicit type implicitly convert to any array type -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 19, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|D1 & D2 |D1 --- Comment #13 from yebblies <yebblies@gmail.com> 2012-07-20 01:06:50 EST --- Fixed for D2 only. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 19, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 --- Comment #14 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-19 09:13:24 PDT --- Pull request for D1: https://github.com/D-Programming-Language/dmd/pull/1056 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 21, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 --- Comment #15 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-20 23:34:03 PDT --- Fixed for D1: https://github.com/9rnsr/dmd/commit/d7a1b1cbb7bceaee00ffb6733bd1d267dd069550 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 21, 2012 [Issue 2006] Empty array literals with explicit type implicitly convert to any array type | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2006 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- 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