D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2802 - VariantN.opCmp!(T) fails when T != VariantN
Summary: VariantN.opCmp!(T) fails when T != VariantN
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: Andrei Alexandrescu
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2009-04-05 14:01 UTC by David Simcha
Modified: 2015-06-09 01:18 UTC (History)
2 users (show)

See Also:


Attachments
Patch to fix bug 2802. (174 bytes, patch)
2009-04-05 14:10 UTC, David Simcha
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-04-05 14:01:22 UTC
import std.stdio, std.variant;

void main() {
    auto v = Variant(1);
    writeln(v < 1);
}

Results:
E:\dmd\windows\bin\..\..\src\phobos\std\variant.d|634|Error: no property 'type' for type 'int'|
E:\dmd\windows\bin\..\..\src\phobos\std\variant.d|634|Error: constructor std.variant.VariantException.this (immutable(char)[] s) does not match parameter types (TypeInfo,int)|
E:\dmd\windows\bin\..\..\src\phobos\std\variant.d|634|Error: cannot implicitly convert expression (1) of type int to object.TypeInfo|
E:\dmd\windows\bin\..\..\src\phobos\std\variant.d|634|Error: cannot cast int to object.TypeInfo|
E:\dmd\windows\bin\..\..\src\phobos\std\variant.d|5|Error: template instance std.variant.VariantN!(maxSize).VariantN.opCmp!(int) error instantiating|

The problem is a really simple one-liner.  Patch to follow.
Comment 1 David Simcha 2009-04-05 14:10:30 UTC
Created attachment 314 [details]
Patch to fix bug 2802.

Actually more like a two-liner since I also added a case to the unittest to show that the patch works.
Comment 2 David Simcha 2009-12-01 06:21:07 UTC
Fixed SVN.
Comment 3 Walter Bright 2009-12-06 00:50:16 UTC
Fixed dmd 2.037