Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fails to recognise condition in expr #18

Open
serjek opened this issue Nov 20, 2020 · 1 comment
Open

Merge fails to recognise condition in expr #18

serjek opened this issue Nov 20, 2020 · 1 comment

Comments

@serjek
Copy link

serjek commented Nov 20, 2020

This does not work:

var a = {v: "none"};

function getResult(isYes:Bool)
	return tink.Anon.merge(a, isYes ? {v:"it works"} : {});

trace(getResult(true));
trace(getResult(false));

OTOH this works:

tink.Anon.merge(a, {v: isYes ? "it works" : ""});

I believe it is not trivial thing to fix (if even possible) so adding a compilation error and a notion to readme about this kinds of limitation would be useful.

@kevinresol
Copy link
Member

kevinresol commented Nov 22, 2020

I think the readme has clearly stated that the function takes expressions and the supported expressions are already listed.

This falls into the third case and the reason of your problem can be revealed by a $type print:

$type(isYes ? {v:"it works"} : {}); // {}

i.e. no fields will get merged from this expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants