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

Fix a compile error on JS target (fix #50) #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jgranick
Copy link

Using an optional function parameter of a basic type (such as Bool) results in compile errors.

For example, adding to the Calculator mock example:

public function add (value1:Float, value2:Float, _round:Bool = false):Float {
    if (_round) return round(value1 + value2);
    return value1 + value2;
}

Results in this error:

src/math/Calculator.hx:13: lines 13-16 : Field add overloads parent class with different or incomplete type
src/math/Calculator.hx:13: lines 13-16 : value : Float -> value2 : Float -> ?_round : Null<Bool> -> Float should be value : Float -> value2 : Float -> ?_round : Bool -> Float
src/math/Calculator.hx:13: lines 13-16 : Null<Bool> should be Bool

Returning null as the default parameter on all dynamic targets for macro.tools.ComplexTypes results in forcing type Bool to be Null<Bool>, but this was not the original type. On current Haxe development builds, this is the error, on Haxe 3.2.1 it printed "src/Main.hx:28: characters 15-25 : math.CalculatorMocked has no field round" which is more confusing.

Removing the Tools.isStaticPlatform() conditional seems to fix this condition on JavaScript.

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

Successfully merging this pull request may close these issues.

1 participant