From 2e896e3360ee6f486dfa47c80e6640736d738258 Mon Sep 17 00:00:00 2001 From: flywind Date: Mon, 22 Feb 2021 02:14:18 -0600 Subject: [PATCH] fix #17118 (#17119) [backport:1.2] * fix js unsigned integer * Use `std` prefix for standard library modules * fix #17118 (cherry picked from commit 32bf10126c0e9d75e4b17034d32025e7682f5ec1) --- compiler/vmops.nim | 11 ++++++++++- lib/pure/math.nim | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/compiler/vmops.nim b/compiler/vmops.nim index d4818ce6bd..518d87b8e0 100644 --- a/compiler/vmops.nim +++ b/compiler/vmops.nim @@ -11,7 +11,8 @@ #import vmdeps, vm from math import sqrt, ln, log10, log2, exp, round, arccos, arcsin, arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc, - floor, ceil, `mod` + floor, ceil, `mod`, cbrt, arcsinh, arccosh, arctanh, erf, erfc, gamma, + lgamma from os import getEnv, existsEnv, dirExists, fileExists, putEnv, walkDir, getAppFilename from md5 import getMD5 @@ -142,6 +143,7 @@ proc registerAdditionalOps*(c: PCtx) = setResult a, c.config.projectPath.string wrap1f_math(sqrt) + wrap1f_math(cbrt) wrap1f_math(ln) wrap1f_math(log10) wrap1f_math(log2) @@ -150,6 +152,9 @@ proc registerAdditionalOps*(c: PCtx) = wrap1f_math(arccos) wrap1f_math(arcsin) wrap1f_math(arctan) + wrap1f_math(arcsinh) + wrap1f_math(arccosh) + wrap1f_math(arctanh) wrap2f_math(arctan2) wrap1f_math(cos) wrap1f_math(cosh) @@ -162,6 +167,10 @@ proc registerAdditionalOps*(c: PCtx) = wrap1f_math(trunc) wrap1f_math(floor) wrap1f_math(ceil) + wrap1f_math(erf) + wrap1f_math(erfc) + wrap1f_math(gamma) + wrap1f_math(lgamma) wrap1s(getMD5, md5op) diff --git a/lib/pure/math.nim b/lib/pure/math.nim index c8a433559a..fdca578835 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -1185,6 +1185,22 @@ when isMainModule: doAssert(classify(trunc(f_nan.float32)) == fcNan) doAssert(classify(trunc(0.0'f32)) == fcZero) + block: + when not defined(js): + # check for no side effect annotation + proc mySqrt(num: float): float {.noSideEffect.} = + # xxx unused + sqrt(num) + + # check gamma function + doAssert gamma(5.0) == 24.0 # 4! + doAssert lgamma(1.0) == 0.0 # ln(1.0) == 0.0 + doAssert erf(6.0) > erf(5.0) + doAssert erfc(6.0) < erfc(5.0) + + when not defined(js) and not defined(windows): # xxx pending bug #17017 + doAssert gamma(-1.0).isNaN + block: # sgn() tests assert sgn(1'i8) == 1 assert sgn(1'i16) == 1