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

optional argument default value lost when inlining a function call #7032

Closed
nadako opened this issue May 16, 2018 · 4 comments
Closed

optional argument default value lost when inlining a function call #7032

nadako opened this issue May 16, 2018 · 4 comments

Comments

@nadako
Copy link
Member

nadako commented May 16, 2018

class Test {
    static function main() {
        f(null);
    }
    
    static function f(p) {
        trace(f2(p));
    }
    
    static inline function f2(p = 10) {
        return p;
    }
}

generates:

Test.f = function(p) {
	console.log("root/program/Test.hx:7:",p);
};

although it should insert the null-check for the p argument at the call site.

so this snipped traces null instead of 10 as it would if we remove the inline modifier

@nadako
Copy link
Member Author

nadako commented May 16, 2018

not a regression btw

@Simn
Copy link
Member

Simn commented Jun 6, 2018

This is related to #3826 and possibly #6972.

@Simn
Copy link
Member

Simn commented Jul 1, 2019

Note that this currently doesn't deal with the p = 10 case, only ?p = 10. This is a bit of a mess on static targets so I would like to think about it some more.

@Simn
Copy link
Member

Simn commented Jun 5, 2020

This now generates this:

Main.f = function(p) {
	var p1 = p;
	if(p == null) {
		p1 = 10;
	}
	console.log("source/Main.hx:7:",p1);
};

Which looks correct to me.

@Simn Simn closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants