Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 23, 2014 [Issue 12620] Compiler picks lesser template specialization match for float array alias value parameters | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12620 --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> --- (In reply to Andrej Mitrovic from comment #0) > ----- > template Foo(alias sym) { pragma(msg, "Foo1"); } > template Foo(alias int[] sym) { pragma(msg, "Foo2"); } > template Foo(alias float[] sym) { pragma(msg, "Foo3"); } > > void main() > { > alias foo1 = Foo!(1); // instantiates #1, ok > alias foo2 = Foo!([1]); // instantiates #2, ok > alias foo3 = Foo!([1.0]); // instantiates #1 instead of #3! > } > ----- Changing the third overload to use double[] instead of float[] fixes this. So it must be some issue with a missed implicit conversion. -- |
January 25, 2015 [Issue 12620] Compiler picks lesser template specialization match for float array alias value parameters | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12620 mfx <markus@oberhumer.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |markus@oberhumer.com --- Comment #2 from mfx <markus@oberhumer.com> --- Not a bug. You must use 1.0f (note the "f") if you want a float constant. alias foo3 = Foo!([1.0f]); -- |
January 25, 2015 [Issue 12620] Compiler picks lesser template specialization match for float array alias value parameters | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12620 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |k.hara.pg@gmail.com --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> --- (In reply to mfx from comment #2) > Not a bug. You must use 1.0f (note the "f") if you want a float constant. > > alias foo3 = Foo!([1.0f]); Ah, could be. I guess it makes sense to prefer matching the version which retains the matching type (and retains the full range of the type this way) rather than tries to implicitly convert it. I'll CC Kenji on his opinions. -- |
July 03, 2017 [Issue 12620] Compiler picks lesser template specialization match for float array alias value parameters | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12620 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dlang-bugzilla@thecybershad | |ow.net Resolution|--- |INVALID --- Comment #4 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> --- (In reply to Andrej Mitrovic from comment #3) > Ah, could be. I guess it makes sense to prefer matching the version which retains the matching type (and retains the full range of the type this way) rather than tries to implicitly convert it. Err, but you can't implicitly convert a double[] to a float[]. I mean, it works when you assign it: float[] arr = [1.0]; So does with int->byte: byte[] arr = [1]; but int->byte conversion fails with your example too: template Foo(alias sym) { pragma(msg, "Foo1"); } template Foo(alias byte[] sym) { pragma(msg, "Foo2"); } void main() { alias foo1 = Foo!([1]); // prints Foo1 } So, this issue is either invalid, or it's about an enhancement request to extend the same type of implicit conversion used for initialization / literal assignment to alias parameters. Seeing how this issue as initially formulated was based on a misunderstanding, and that it was filed 3 years ago, I'll be closing this, but feel free to reopen if you disagree. -- |
July 03, 2017 [Issue 12620] Compiler picks lesser template specialization match for float array alias value parameters | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12620 --- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> --- Jesus sorry to spam Vladimir, but just how many issues have I filed over the years? lol. Thanks for taking care of this. -- |
Copyright © 1999-2021 by the D Language Foundation