Bug 8837 – BigInt needs better operator template constraints

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-17T13:39:00Z
Last change time
2013-02-04T20:26:06Z
Keywords
pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-10-17T13:39:56Z
import std.bigint: BigInt; void main() { auto r1 = BigInt(10) / true; auto r2 = BigInt(10) /= true; } DMD 2.061alpha gives: ...\dmd2\src\phobos\std\bigint.d(135): Error: operation not allowed on bool 'y' ...\dmd2\src\phobos\std\bigint.d(258): Error: template instance std.bigint.BigInt.opOpAssign!("/",bool) error instantiating test.d(3): instantiated from here: opBinary!("/",bool) test.d(3): Error: template instance std.bigint.BigInt.opBinary!("/",bool) error instantiating If this operation is not allowed, then maybe it's better to disallow it statically (maybe with a template constraint), to give a nicer/more clean error message.
Comment #1 by andrej.mitrovich — 2013-02-04T13:08:07Z
Comment #2 by github-bugzilla — 2013-02-04T20:15:12Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/7c616db71a5f7b1568a46a0044dcb636b2bc7ee6 Fixes Issue 8837 - BigInt needs better operator constraints. https://github.com/D-Programming-Language/phobos/commit/295ff3b64d9e58d347ff898402e066e39f9174ea Merge pull request #1112 from AndrejMitrovic/Fix8837 Issue 8837 - BigInt needs better operator constraints.