clemos / haxe-js-kit

Haxe tools and externs for Javascript and Node.js
MIT License
128 stars 42 forks source link

Warning : Extern non-inline function may not have an expression #179

Open fullofcaffeine opened 5 years ago

fullofcaffeine commented 5 years ago

Getting the following warnings when compiling with Haxe 4 RC2:

/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:25: characters 2-8 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:26: characters 2-7 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:27: characters 2-8 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:28: characters 2-10 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:29: characters 2-11 : Warning : Extern non-inline function may not have an expression
... and a lot more

Full list of errors have been pasted here: https://www.pastiebin.com/5ce653c96e3bd

Any ideas what this is about and how to fix them? If not, I'd be happy if I just could suppress these warnings, is that possible?

clemos commented 5 years ago

Mh all I know is these lines are generated with this macro: https://github.com/clemos/haxe-js-kit/blob/develop/util/CopyMethods.hx#L31 I guess fun.expr should be nulled somewhere

varadig commented 5 years ago

I try to compile with Haxe 4 RC3, and also got this warnings. But I also use mongoose and I got error too

/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/support/Error.hx:5: characters 6-14 : Warning : This typedef is deprecated in favor of js.lib.Error
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/support/Error.hx:5: characters 18-26 : Warning : This typedef is deprecated in favor of js.lib.Error
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/npm/Package.hx:74: lines 74-80 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:59: characters 2-7 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:60: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:61: characters 2-7 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:62: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:63: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:64: characters 2-11 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:65: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:66: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:67: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:68: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:69: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:70: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:71: characters 2-12 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:72: characters 2-13 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:73: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:74: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:75: characters 2-14 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:76: characters 2-12 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:77: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:79: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:80: characters 2-13 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:81: characters 2-15 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:82: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:83: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:84: characters 2-11 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:85: characters 2-7 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:22: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:23: characters 2-7 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:24: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:25: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:26: characters 2-11 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:27: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:28: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:29: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:30: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:31: characters 2-8 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:32: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:33: characters 2-12 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:34: characters 2-13 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:35: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:36: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:37: characters 2-14 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:38: characters 2-12 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:39: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:41: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:42: characters 2-13 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:43: characters 2-15 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:44: characters 2-9 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:45: characters 2-10 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:46: characters 2-11 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/js/npm/express/Middleware.hx:47: characters 2-7 : Warning : Extern non-inline function may not have an expression
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 : error: { field : String, expr : haxe.macro.Expr } has no field quotes
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 :  have: Array<{ field, expr }>
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 :  want: Array<haxe.macro.ObjectField>
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 : For function argument 'fields'
src/model/database/model/User.hx:34: character 1 : Build failure
varadig commented 5 years ago

with 3.4.7 works fine:

{ "version": "3.4.7", "resolveLibs": "scoped" }

fullofcaffeine commented 5 years ago

Does anyone know how to suppress / fix those warnings? It's beyond annoying for me at this point :(

varadig commented 5 years ago

And there is not just a warning, but error too. So can’t use js-kit of mongoose with haxe 4 :(

fullofcaffeine commented 5 years ago

@varadig What error are you experiencing when using the mongoose externs? So far, js-kit has worked relatively well with Haxe 4 for me, but I have only used the Express externs.

varadig commented 5 years ago

@fullofcaffeine , yes I have compile error

/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 :  have: Array<{ field, expr }>
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 :  want: Array<haxe.macro.ObjectField>
/Users/varadig/haxe/haxe_libraries/js-kit/0.0.3/github/d9615f45a332fca9ac868093fca96da5077a1e93/util/Mongoose.hx:327: characters 30-36 : For function argument 'fields'
src/model/database/model/User.hx:34: character 1 : Build failure

So I can't compile my project if I use haxe 4.x

fullofcaffeine commented 5 years ago

Mh all I know is these lines are generated with this macro: https://github.com/clemos/haxe-js-kit/blob/develop/util/CopyMethods.hx#L31 I guess fun.expr should be nulled somewhere

@clemos I've tried nullifying func.expr but Haxe won't compile if so, it complains that "Function must have a body". If I enable AInline for all fields, it seems to misgenerate the functions (don't ask me how as I don't know) so that calling any of the middleware aliases (i.e .post, get ...) for example, will always generate a ['m-search'].

Check my message here for more details: https://community.haxe.org/t/weird-warning-with-extern-classes/1511/5?u=fullofcaffeine.

clemos commented 5 years ago

You may want to try to just add expr: null as part of var f = { ... } initial assignment. The rest of the code should correctly overwrite expr and access if needed (ie if the method needs to be renamed)

fullofcaffeine commented 5 years ago

But expr is part of func not f (Field), right?

On Sun, Aug 4, 2019 at 1:46 PM Clément Charmet notifications@github.com wrote:

You may want to try to just add expr: null as part of var f = { ... } initial assignment. The rest of the code should correctly overwrite expr and access if needed (ie if the method needs to be renamed)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clemos/haxe-js-kit/issues/179?email_source=notifications&email_token=AAAT2YGGS5NIQOP4BLSOYKTQC4PWTA5CNFSM4HO255B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QHLCQ#issuecomment-518026634, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAT2YHUGYA4GMPITT5K7UTQC4PWTANCNFSM4HO255BQ .

fullofcaffeine commented 5 years ago

@clemos I've added expr: null as you suggested, here (CopyMethods.hx):

jskit

But then I get the following errors:

haxe build-server.hxml                                            [2.5.0]
src/hx/server/externs/util/CopyMethods.hx:75: characters 20-21 : { pos : haxe.macro.Position, name : String, meta : Array<{ pos : haxe.macro.Position, params : Array<haxe.macro.Expr>, name : String }>, kind : haxe.macro.FieldType, expr : Unknown<0>, access : Array<haxe.macro.Access> } should be haxe.macro.Field
src/hx/server/externs/util/CopyMethods.hx:75: characters 20-21 : { pos : haxe.macro.Position, name : String, meta : Array<{ pos : haxe.macro.Position, params : Array<haxe.macro.Expr>, name : String }>, kind : hax... has extra field expr
src/hx/server/externs/util/CopyMethods.hx:75: characters 20-21 : For function argument 'x'
src/hx/server/externs/express/Middleware.hx:68: characters 1-8 : Build failure

Using Haxe 4RC3. The version of js-kit is git HEAD, although I copied only the express externs (and related types) over to my app in order to make it easier to modify locally.

Any hints?

clemos commented 5 years ago

You're right. You may try

if ( method != verb ) {
   ...
} else {
    fun.expr = null;
}
melMass commented 4 years ago

I had the same issue using the express externs.

@clemos your fix generate the following error:

    express/Middleware.hx:29: characters 37-47 : Function body required

So I did some debugging and the issue is the key m-search in Middleware.hx, toIdentifier converts it to mSearch and generates the error, for now, I simply remove m-search completely but do you have a solution?

Thanks

Windaas commented 3 years ago

Hi, I'm new in Haxe and is trying to build node/express web app trying js-kit but has errors like these:

Getting the following warnings when compiling with Haxe 4 RC2:

/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:25: characters 2-8 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:26: characters 2-7 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:27: characters 2-8 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:28: characters 2-10 : Warning : Extern non-inline function may not have an expression
/home/fullofcaffeine/haxe/haxe_libraries/js-kit/0.0.3/git/f5c1e23e0ef5c5b04288d03f8fa3af746a70c9d3/js/npm/express/Middleware.hx:29: characters 2-11 : Warning : Extern non-inline function may not have an expression
... and a lot more

Full list of errors have been pasted here: https://www.pastiebin.com/5ce653c96e3bd

Any ideas what this is about and how to fix them? If not, I'd be happy if I just could suppress these warnings, is that possible?

Follow the instruction on:

You're right. You may try

if ( method != verb ) {
   ...
} else {
    fun.expr = null;
}

and got Error as:

I had the same issue using the express externs.

@clemos your fix generate the following error:

    express/Middleware.hx:29: characters 37-47 : Function body required

So I did some debugging and the issue is the key m-search in Middleware.hx, toIdentifier converts it to mSearch and generates the error, for now, I simply remove m-search completely but do you have a solution?

Thanks

I changed var r = ~/[^a-zA-Z0-9_]+/g; to var r = ~/[^a-zA-Z0-9_\-]+/g; to get around the error, but it still got:

/home/oceanet/haxelib/js-kit/git/js/support/Error.hx:5: characters 6-14 : Warning : This typedef is deprecated in favor of js.lib.Error
/home/oceanet/haxelib/js-kit/git/js/support/Error.hx:5: characters 18-26 : Warning : This typedef is deprecated in favor of js.lib.Error
/home/oceanet/haxelib/js-kit/git/npm/Package.hx:74: lines 74-80 : Warning : Extern non-inline function may not have an expression
/home/oceanet/haxelib/js-kit/git/js/npm/express/Request.hx:21: characters 2-27 : Redefinition of variable path in subclass is not allowed. Previously declared at js.node.http.ClientRequest

How can this be solved?

I'm only tried the "Example basic website" on Matthijs' site. As the last comment was on Mar 30, was this project discontinuous?