D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7132 - [tdpl] Exponential operator ^^ for integrals does not compile without any import
Summary: [tdpl] Exponential operator ^^ for integrals does not compile without any import
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: TDPL
Depends on:
Blocks:
 
Reported: 2011-12-18 18:13 UTC by Andrei Alexandrescu
Modified: 2014-01-06 12:53 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2011-12-18 18:13:15 UTC
//import std.stdio;

void main() {
    uint base;
    uint exp;
    static assert(is(typeof(base ^^ exp) == uint));
}

test.d(8): Error: static assert  (is(typeof(__error) == uint)) is false

If the import is uncommented, the code compiles.
Comment 1 Don 2011-12-24 04:52:18 UTC
That's because ^^ requires import std.math;
To make it work without the import, we need to move the intpow function out of std.math, and into the runtime.

That's quite reasonable, provided we don't have to do the same for floating point powers.
(To implement floating point powers, most of std.math would need to move to the runtime. In fact to do it with correct rounding, parts of bigint would be required as well).
Comment 2 Andrej Mitrovic 2014-01-06 12:53:12 UTC
Works since v2.064.