timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

js; `Math.trunc` polyfill is unconditionally generated #514

Open timotheecour opened 3 years ago

timotheecour commented 3 years ago

it should be eliminated by dead code elimination but isn't:

Example

in the simplest program(eg: discard) js output is:

/* Generated by the Nim Compiler v1.5.1 */
var framePtr = null;
var excHandler = 0;
var lastJSError = null;
if (!Math.trunc) {
  Math.trunc = function(v) {
    v = +v;
    if (!isFinite(v)) return v;
    return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
  };
}

Additional Information

1.5.1 d2f4f25b5660454c2483ab1249195b3a3d037588

metagn commented 3 years ago

Main repo issue https://github.com/nim-lang/Nim/issues/16144