Display directive

Hej all !

I used to have statements like #if display in my code and it seems it doesn’t work anymore, like it doesn’t enter this statement on display mode. Did something changed about that please ?

Note : I’m on last nightly builds…

There are two cases where display is expected not to be defined right now:

Both of these can be disabled with a setting - if you still have issues after that, there might be a bug.

Thanks for your reply !

I didn’t know about this behaviour in completion cache, it comes from that I think.

Thanks again :slight_smile:

It’s maybe a stupid question but couldn’t we have display using completion cache ? Or maybe just add -D display to the regular compilation with --no-output ? Or maybe we can define it by ourselves somewhere ?

No, that would cause problems. You can however check for --no-output like this:

Ok, so if I understand well, I have to write a macro which checks if there is --no-output and then define display by myself right ?
BTW, do you know how disable completion cache in VSCode ? Because I tried to disable it and it still doesn’t work :confused:

Well, I was sort of assuming you already have a macro, because that’s usually where you want to check for this… :slight_smile: Where else do you need #if display?

And no, you definitely don’t want to define display yourself, that will almost certainly cause compiler errors.

I have a #if display in order to add or not @:forward on my abstract…
So the only solution is to disable completion cache right ? If so, can you show me where can I disable it becasue I’ve tried and it seems not working :confused:

Huh, but why? :slight_smile:

The setting documented in the wiki should work fine. Maybe it’s not the completion cache build after all that’s the problem here.

Just to ease compiler because I don’t need @:forward on my abstract for completion…
I don’t know if it’s cache completion or not that why I ask if something changed about display because my whole thing worked fine before and know it just doesn’t enter the if statement and it doesn’t work anymore.
When I remove this check #if display all works fine but I just want it to have the same behaviour as before even if I can let the @:forward during completion… It shouldn’t be a problem…

Well, as I said earlier:

Ok, I’ll dig around that…
And for the future will it be the default behaviour for cache completion ? (no having displaydefined ?)
That’s pitty no being able to use this compiler directive using cache completion :confused:

I think you misunderstood. The completion cache build has never had display defined, nor should it matter for this use case. Having a completion cache does not mean you can’t use #if display during actual display requests.

Maybe I misunderstand yes.

Let me try to explain : I have a TextsBuilder a kind of haxe.XmlProxy that builds static class fields from the ids from the xml that contains my strings in order to have them during completion.
All worked fine before, and since I don’t know when, I haven’t modified anything and now it does’nt work anymore just because of the #if display somewhere. If I remove this #if display, all works fine with or without cache completion. If I let it, both with or without cache completion, it doesn’t display my fields.

It sounds like you might want to isolate this to a MCVE and probably report it as a Haxe issue.

Here you can see why I need to play with @:forward, in order to not have these fields on runtime because it won’t be resolved by DotAccess : package ftk;import haxe.macro.Context;import haxe.macro.Expr;/** * . - Pastebin.com

That doesn’t exactly look like a MCVE to me (seems to depend on some external file XML).

I’ve seen your answer after posting. I’ll write a “MCVE”… :ok_hand:

Here is the minimaliest example I could do :

class Main{
	static function main(){
		Texts.list
	}
}

/*class Texts {
    public static var list  : DotAccess;
}
 
//#if display
@:forward
//#end
abstract DotAccess(MyList) from MyList to MyList {}
 
class MyList{
	public var foo : String;
}*/

With build : haxe -main Main -js jean-claude-van-damme.js

Strange thing is that it works if the code is inside the same file (here when you remove comments) but when you put the fragment that is commented into a separate file Texts.hx, it doesn’t work anymore.
When I write “work”, I mean on “completion-time”, when you put the dot after Texts.list in static main, it gives foo in completion without #if display but it doesn’t when there is this statement.

I hope it can help.