HaxeFoundation / hxcpp

Runtime files for c++ backend for haxe
Other
298 stars 190 forks source link

HXCPP Assertion Failed on EnumValue #127

Closed aaulia closed 10 years ago

aaulia commented 10 years ago

The following code would not build on HXCPP (3.1.39 and git).

//
// Main.hx
//
package ;

enum Config 
{
    ValueOne(one : Int);
    ValueTwo(one : Int, two : Int);
}

class Main 
{
    public static function main()
    {
        handleEnumValue(ValueOne(123));
    }

    static function handleEnumValue(v : EnumValue)
    {
        switch (v) {
            case ValueOne(one):      trace(one);
            case ValueTwo(one, two): trace(one, two);
            case _:
                throw 'Error Config Value $v';
        }
    }
}
#
# hxml
#
-main Main 
-cpp cpp 
-debug 

It build correctly for Neko and Flash, on cpp it give me File "gencpp.ml", line 1861, characters 75-81: Assertion failed

aaulia commented 10 years ago

Following up with this. I installed Haxe dev build (3.2.0) and the above code build with no hitch. I would close this issue, but the following code still failed to build (while successfully built on neko, js and swf target). Should I open a new issue?

// Main.hx
package ;

import Foo;
import Bar;
import CommonConfig;

class Main 
{
    public static function main()
    {
        var foo = new Foo();
        var bar = new Bar();

        foo.handleEnumValue(ValueOne(123));
        bar.handleEnumValue(ValueOne(321));
    }

}
// CommonConfig.hx
package ;

enum CommonConfig 
{
    ValueOne(one : Int);
    ValueTwo(one : Int, two : Int);
}
// Foo.hx
package ;

import CommonConfig;

class Foo 
{
    public function new() {}
    public function handleEnumValue(v : EnumValue) 
    {
        switch (v)
        {
            case ValueOne(one): trace("foo", one);
            case ValueTwo(one, two): trace("foo", one, two);
        }
    }
}
// Bar.hx
package ;

import CommonConfig;

class Bar 
{
    public function new() {}
    public function handleEnumValue(v : EnumValue)
    {
        switch (v)
        {
            case ValueOne(one): trace("bar", one);
            case ValueTwo(one, two): trace("bar", one, two);
        }
    }

}

with error

Foo.cpp

./src/Foo.cpp(56) : error C2039: 'CommonConfig' : is not a member of '`global namespace''

./src/Foo.cpp(56) : error C2227: left of '->__Param' must point to class/struct/union/generic type

        type is ''unknown-type''

./src/Foo.cpp(56) : error C3861: 'CommonConfig': identifier not found

./src/Foo.cpp(85) : error C2039: 'CommonConfig' : is not a member of '`global namespace''

./src/Foo.cpp(85) : error C2227: left of '->__Param' must point to class/struct/union/generic type

        type is ''unknown-type''

./src/Foo.cpp(85) : error C3861: 'CommonConfig': identifier not found

./src/Foo.cpp(87) : error C2039: 'CommonConfig' : is not a member of '`global namespace''

./src/Foo.cpp(87) : error C2227: left of '->__Param' must point to class/struct/union/generic type

        type is ''unknown-type''

./src/Foo.cpp(87) : error C3861: 'CommonConfig': identifier not found
hughsando commented 10 years ago

This should be fixed in the haxe git version. Thanks for the code example.