Open Bug 1497011 Opened 1 year ago Updated 4 months ago

[meta] Bugs that wouldn't exist if JavaScript were a statically typed language

Categories

(Core :: JavaScript Engine, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: botond, Unassigned)

References

Details

(Keywords: meta)

I fairly regularly come across (and often myself introduce) bugs that wouldn't exist if JavaScript were a statically typed language, because they would have been caught at "compile time".

I'm creating this metabug to hang all such bugs off of, and encourage others to do the same.

I'm filing this in the JS engine component because, while the language itself may never become statically typed, there may be a role for tooling to catch some of these categories of bugs statically.
Bug 1452820, a long-standing intermittent test failure, was caused because a developer wrote "window.scrollYMax" instead of "window.scrollMaxY". The resulting "undefined" value then silently produced "false" in a comparison, rather than producing an exception or other error.

In a statically typed language, this would have been caught at compile time with an error like "property 'scrollYMax' does not exist".
Blocks: 1452820
Bug 1496864 is caused because a JavaScript function that inteprets its parameter in one coordinate space (screen units) is passed an argument in another coordinate space (CSS units).

In a statically typed language, this could have been caught at compile time if we used different types to represent different coordinates, as we do in our C++ code.
Blocks: 1496864
Priority: -- → P5
see also : bug 1308901 (using Flow for static analysis of JS, which includes type checking )

The meta keyword is there, the bug doesn't depend on other bugs and there is no activity for 12 months.
:sdetar, maybe it's time to close this bug?

Flags: needinfo?(sdetar)
Summary: Bugs that wouldn't exist if JavaScript were a statically typed language → [meta] Bugs that wouldn't exist if JavaScript were a statically typed language
Flags: needinfo?(sdetar)
You need to log in before you can comment on or make changes to this bug.