HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 656 forks source link

Issue 1199 - search by Enum in Spod Macro throw a compiler error - haxe #1199

Closed issuesbot closed 9 years ago

issuesbot commented 11 years ago

[Google Issue #1199 : https://code.google.com/p/haxe/issues/detail?id=1199] by francois...@gmail.com, at 28/09/2012, 14:22:48

@ :native('_xbc') enum GameMode {
    GM_PROGRESSION; 
    GM_LEAGUE;  
    GM_MISSION;
    GM_CLAN;
    }

class Party extends sys.db.Object

{
    public var id : SId;
    public var gameId : SInt;
    public var userId : SInt;
    ... 
    public var mode : SEnum<GameMode>;
    }

var mode:GameMode = ....;

return db.Party.manager.search( $userId == App.current.user.id && $gameId == gameId && $endTime!=null && $mode==mode, { orderBy:-id, limit:limit },lock );

throws a "Unknown constructor mode" at compile time.

It doesnt happen if I use one of the Enum value directly instead of a variable. ( like GM_LEAGUE instead of 'mode' )

issuesbot commented 11 years ago

[comment from simon.kr...@simn.de, published at 06/10/2012, 13:26:53]

issuesbot commented 11 years ago

[comment from simon.kr...@simn.de, published at 06/10/2012, 13:27:32]

issuesbot commented 11 years ago

[comment from si...@haxe.org, published at 09/02/2013, 19:09:24] Please post complete examples which can be compiled without building much infrastructure around it manually.

issuesbot commented 11 years ago

[comment from ncanna...@gmail.com, published at 21/02/2013, 08:04:45]

issuesbot commented 11 years ago

[comment from si...@haxe.org, published at 24/02/2013, 17:12:14]

issuesbot commented 11 years ago

[comment from francois...@gmail.com, published at 22/03/2013, 11:08:30] Hi , here is a standalone version of the code. ( tested on haxe 2.11 ) It still throws a "Unknown constructor mode" at compile time.

package ; import sys.db.Types;

class Main

{
    static function main()
    {
        var main = new Main();
    }
    function new() {
        var cnx = sys.db.Mysql.connect({
            host : "localhost",
            port : null,
            user : "root",
            pass : "",
            database : "test",
            socket : null,
        });
        sys.db.Manager.cnx = cnx;
        if ( !sys.db.TableCreate.exists(Party.manager) ){
            sys.db.TableCreate.create(Party.manager);
        }
        var mode:GameMode = GM_LEAGUE;
        var p = Party.manager.search( $mode==mode, false );
    }
}
class Party extends sys.db.Object{
    public var id : SId;
    public var gameId : SInt;
    public var userId : SInt;
    public var mode : SEnum;
}
enum GameMode {
    GM_PROGRESSION;
    GM_LEAGUE;
    GM_MISSION;
    GM_CLAN;
}
bablukid commented 10 years ago

Hi I'm still having this bug in a new project ... one year passed since this issue submission , don't forget SPOD guys ;) ...

ginosucc commented 9 years ago

Hi, Maybe i missed something, but the bug is still present in the latest git build. We can't use variable when searching on a SEnum<> spod field. The following code doesn't compile :

package ; import sys.db.Types;

class Main { static function main() { var main = new Main(); } function new() { var t : EnumTest = EnumTest.second; TestSPOD.manager.search($test == first); TestSPOD.manager.search($test == EnumTest.first); // Error : Should be a constant constructor TestSPOD.manager.search($test == t); // Error : Unknown constructor t TestSPOD.manager.search($test == (cast t)); // Error : Should be a constant constructor } } class TestSPOD extends sys.db.Object{ public var id : SId; public var test : SEnum< EnumTest >; } enum EnumTest { first; second; }

waneck commented 9 years ago

You're right! Sorry about this