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

Overriding functions with Dynamic param #4900

Closed
kevinresol opened this issue Mar 5, 2016 · 11 comments
Closed

Overriding functions with Dynamic param #4900

kevinresol opened this issue Mar 5, 2016 · 11 comments
Milestone

Comments

@kevinresol
Copy link
Contributor

class Main extends Test
{
    static function main(){}
    override function test(_, _){}
}

class Test
{
    public function new(){}
    public function test(a:Int, b:Dynamic){}
}

Fails with: Field test overloads parent class with different or incomplete type (Haxe: b0b16f2)

Compiles fine when changing type of b to non-Dynamic, or specify (_, b:Dynamic) in the override

@Simn
Copy link
Member

Simn commented Mar 5, 2016

That happens because monomorphs are not bound to Dynamic. Not worth fixing in my opinion, it's good practice to type-hint your function arguments and not doing so can lead to other inference issues as well.

@Gama11
Copy link
Member

Gama11 commented Mar 5, 2016

Would it help if there were special semantics for _? If the programmer says "I don't care about the argument", that includes "I don't care about the argument type", so it seems annoying that you'd have to specify it.

@Simn
Copy link
Member

Simn commented Mar 5, 2016

Do you mean automatically inferring _ to be Dynamic?

@kevinresol
Copy link
Contributor Author

btw this is a breaking change because it worked in 3.2.1

@Gama11
Copy link
Member

Gama11 commented Mar 5, 2016

Perhaps, yeah? Although that seems potentially dangerous if the compiler doesn't also make sure _ really is unused.

@kevinresol
Copy link
Contributor Author

Oh man... I thought _ has a special semantic meaning from the beginning and that explains why I can put two parameters of the same name. And I just found that I have been WRONG. I can actually write a function like function test(a:Int, a:Dynamic){} ....

@Gama11
Copy link
Member

Gama11 commented Mar 5, 2016

Yeah, that seems like something that can introduce subtle bugs. Maybe it's a good idea to only allow that for _ and if _ is unused?

@Simn
Copy link
Member

Simn commented Mar 5, 2016

@kevinresol: Yes, that comes from fixing #4378 which intentionally allowed Dynamic variance. I'll have to check the regression though.

@Simn
Copy link
Member

Simn commented Mar 5, 2016

@Gama11: See #4381.

@kevinresol
Copy link
Contributor Author

I am not sure what I expect here, given that _ actually doesn't have special meaning...
Please close this at will.

@Simn Simn modified the milestone: 3.4 Mar 16, 2016
@Simn Simn modified the milestones: 3.4, 4.0 Jan 9, 2017
@Simn
Copy link
Member

Simn commented Sep 23, 2017

I still don't think it's worth fixing this, so I'll go ahead and close it.

@Simn Simn closed this as completed Sep 23, 2017
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

3 participants