Bug 3832 – ^^0.5 with no imports

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-02-18T12:55:00Z
Last change time
2015-06-09T01:27:41Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-02-18T12:55:44Z
This doesn't compile and produces many complex error messages, the compiler can't find std.math.sqrt: void main() { double x = 5 ^^ 0.5; }
Comment #1 by bearophile_hugs — 2010-04-14T13:43:14Z
With dmd 2.043 that program generates the error messages: test.d(2): Error: must import std.math to use ^^ operator test.d(2): Error: undefined identifier module test.std test.d(2): Error: no property 'math' for type 'void' Error: no property 'sqrt' for type 'int' test.d(2): Error: function expected before (), not __error of type int That can be improved a little (and they are too many). Don has noted that the implementation of X^^Y when Y is a floating point reqires several function of std.math, and it's not an used frequently operation in D code (on the other hand X^^0.5 is more common, and it just requires sqrt, that doesn't require much code). So it's possible to require the import std.math when a X^^FP is used. This is not nice, because it seems unnatural to require module imports to use a built-in operator, but it can be an acceptable compromise on a practical basis (if such compromise is adopted, the D documentation has to explain it.)
Comment #2 by clugdbug — 2010-11-05T01:24:54Z
Fixed DMD2.045