Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.6.0 Beta2
-
None
Description
Consider the following code
function greaterThanTwo(input: int) : bool { return input > 2 } property string foo: ... property bool bar: greaterThanTwo(foo)
qmlsc will happily compile this code and qmllint has no complaints about it either. Passing foo to greaterThanTwo implicitly converts the string to int, which may or may not work.
This is probably the expected behavior from a JS point of view, so I wouldn't necessarily call this a bug. With my C++ mindset however I find this very unexpected and would have liked this to not work, since it suggests that there is a bug in my code.
I think it would be good if QML was stricter about this kind of conversion, if only as an opt-in to not break existing code