Bug 8236 – Wrong error message in creating struct from vector operation

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-06-14T02:48:00Z
Last change time
2014-07-17T20:08:40Z
Keywords
diagnostic
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-06-14T02:48:54Z
struct Foo { int[2] v; Foo halve() { return Foo(v[] / 2); } } enum f = Foo([10, 20]).halve(); void main() {} I think the given error message is wrong because I think there is no need for an implicit conversion to int (dmd 2.060alpha): test.d(4): Error: cannot implicitly convert expression (this.v[] / 2) of type int[] to int test.d(7): called from here: Foo([10,20]).halve() (Also, the code that implements the vector operations needs a CTFE guard that disallows the ASM, unless the compiler just sets/assumes to be always false the availability of asm at compile-time).
Comment #1 by hsteoh — 2014-07-17T18:52:59Z
On git HEAD, the error message is now: ---- test.d(4): Error: cannot implicitly convert expression (this.v[] / 2) of type int[] to int[2] test.d(7): called from here: Foo([10, 20]).halve() ---- Is this acceptable?
Comment #2 by bearophile_hugs — 2014-07-17T20:08:40Z
(In reply to hsteoh from comment #1) > Is this acceptable? Yes. Closed. And regarding the ASM guard with __ctfe for array operators, I guess it's stuff for a different enhancement request...