cristicbz / scid

Scientific library for the D programming language
Boost Software License 1.0
23 stars 8 forks source link

Circular Dependency-Related Breakage With 2.059 #87

Closed dsimcha closed 12 years ago

dsimcha commented 12 years ago

I still can't wrap my head around how to fix this, but here's a reduced case that should at least show what the root of the problem is. Basically, isScalar and closureOf circularly depend on each other in a subtle way.

struct ExternalMatrix {}

template isScalar( T ) {
    enum isScalar = is(typeof({
        T x;
        x = x / x;
    })) ;
}

import std.traits;
enum Closure {  Scalar }

Expression!( op, Unqual!Lhs, Unqual!Rhs ) expression( string op, Lhs, Rhs )( auto ref Lhs lhs, auto ref Rhs rhs ) {}

struct Expression( string op_, Lhs_, Rhs_ = void ) {    
    enum rhsClosure = closureOf!Rhs_;
}

template Operand( Closure closure_ ) {      
    auto opBinary( string op, NewRhs )( auto ref NewRhs newRhs_ ) {
        return expression!"+"( this, newRhs_ );
    }
}

template closureOf( T ) {
    static if( isScalar!(Unqual!T) || !isScalar!(Unqual!T)) { 
        enum closureOf = Closure.Scalar;
    } 
}

enum StorageOrder { ColumnMajor }

template ExternalMatrixView( ElementOrContainer) {
        alias BasicMatrix!(ExternalMatrix) ExternalMatrixView;
}

struct BasicMatrix( Storage_ ) {    
    mixin Operand!( Closure.Scalar );
}

enum cl = closureOf!(ExternalMatrixView!double);
dsimcha commented 12 years ago

Fixed. I didn't realize before that the obvious fix (making isScalar check for nominal instead of structural type) actually worked but an unrelated problem in an old beta was causing compilation to fail.