hexMachina icon indicating copy to clipboard operation
hexMachina copied to clipboard

MappingDefinition: function with optional params results in compile-time error

Open gene-pavlovsky opened this issue 8 years ago • 2 comments

I'd like to have this in my array of MappingDefinitions, supplies as dependencies to an IDependencyOwner: mapping({fromType: "?String->Void", toValue: fooController.bar, withName: "bar"}).

The dependency owner has this: @Dependency(var bar:?String->Void)

HM 0.35.0 compile error: Missing mappings:[Null<String>->Void|bar] Changing fromType in DSL to Null<String>->Void - the code compiles. But the type is not exactly right (e.g. my function has a default non-null value for the string param).

HM 0.34.0 compile error: Missing mappings:[Dynamic->Void|bar] Changing fromType in DSL to Dynamic->Void - the code compiles. But this is not safe (I can pass e.g. a Bool->Void function and it compiles.

gene-pavlovsky avatar Feb 26 '18 16:02 gene-pavlovsky

Thanks for the report. You're right, optional arguments are not handled by the checker yet. I will add it.

FrancisBourre avatar Feb 27 '18 08:02 FrancisBourre

Thank you! Lovely :)

gene-pavlovsky avatar Feb 27 '18 09:02 gene-pavlovsky