Closed Bug 1497011 Opened 6 years ago Closed 4 years ago

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

Categories

(Core :: JavaScript Engine, enhancement, P5)

enhancement

Tracking

()

RESOLVED WONTFIX

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)

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)

I feel like rolling out TypeScript support in mochitests and other tests written in JS would address this effectively; if there's a tracking bug for that, we could dupe this one over.

Jason, do you have any input on this? Or is there someone else who should way in on this?

Flags: needinfo?(sdetar) → needinfo?(jorendorff)

I would normally leave something like this open. I'm not opposed to rhetorical bugs per se, or to the point being made here. If the list of blocked bugs here were actively maintained, this could be a pretty powerful statement; that said, that is not the situation we're in.

I'm closing this to appease the bot.

RESO WONTFIX seems most accurate, alas.

"Enable TypeScript in Mochitests" sounds like a different bug someone could file (different component, though, please).

Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(jorendorff)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.