Search code examples
cddmd

Weird error when importing module


This is my main file (the one triggering the error) :

/**********************************************************
 **
 ** LOGRAMM
 ** Interpreter
 ** 
 ** (c) 2009-2014, Dr.Kameleon
 **
 **********************************************************
 ** expression.d
 **********************************************************/

module expression;

//================================================
// Imports
//================================================

import std.stdio;
import std.conv;

import components.argument;

//================================================
// C Interface for Bison
//================================================

extern (C) 
{
    void* Expression_new(Expression l, char* op, Expression r) { return cast(void*)(new Expression(l,to!string(op),r)); }
    void* Expression_newFromArgument(Argument a) { return cast(void*)(new Expression(a)); }
}

//================================================
// Functions
//================================================

class Expression
{
    Expression left;
    string operator;
    Expression right;

    Argument arg;

    this(Expression l, string op, Expression r)
    {
        left = l;
        operator = op;
        right = r;

        arg = null;
    }

    this(Argument a)
    {
        arg = a;
    }

    void print()
    {
        writeln("Expression: ");
        if (!arg)
        {
            writeln("\t | Operator: " ~ operator ~ ", Left: ");
            left.print();
            writeln("Right: ");
            right.print();
        }
        else
        {
            writeln("\t | Argument: ");
            arg.print();
        }
    }
}

And this is the error I'm getting (there are like 20 different modules, and it's the first time I'm getting this type of error) :

components/expression.d(21): Error: module argument from file components/argument.d must be imported as module 'argument'

(21 is the import... line at the beginning)

Any idea what's going on here?


P.S.

  • I've been coding for almost 15 hours in a row, so I suppose it could be something really obvious that I'm not able to spot...

  • I've also tried import argument; - but this wouldn't make much difference anyway, since the argument.d file is in the components package, pretty much like any other file that I'm importing in other places...


Solution

  • Try importing the module via import argument;. Alternatively, open the argument.d module and add or change its module declaration to be: module components.argument;.