mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
fixes jsbigint64 regression; keeps convs to Number in danger mode (#23926)
fixes jsbigint64 regression
This commit is contained in:
@@ -2632,7 +2632,13 @@ proc genRangeChck(p: PProc, n: PNode, r: var TCompRes, magic: string) =
|
||||
let src = skipTypes(n[0].typ, abstractVarRange)
|
||||
let dest = skipTypes(n.typ, abstractVarRange)
|
||||
if optRangeCheck notin p.options:
|
||||
return
|
||||
if optJsBigInt64 in p.config.globalOptions and
|
||||
dest.kind in {tyUInt..tyUInt32, tyInt..tyInt32} and
|
||||
src.kind in {tyInt64, tyUInt64}:
|
||||
# conversions to Number are kept
|
||||
r.res = "Number($1)" % [r.res]
|
||||
else:
|
||||
discard
|
||||
elif dest.kind in {tyUInt..tyUInt64} and checkUnsignedConversions notin p.config.legacyFeatures:
|
||||
if src.kind in {tyInt64, tyUInt64} and optJsBigInt64 in p.config.globalOptions:
|
||||
r.res = "BigInt.asUintN($1, $2)" % [$(dest.size * 8), r.res]
|
||||
|
||||
17
tests/js/tdanger.nim
Normal file
17
tests/js/tdanger.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
matrix: ";--d:danger"
|
||||
"""
|
||||
|
||||
block:
|
||||
proc foo() =
|
||||
var name = int64(12)
|
||||
var x = uint32(name)
|
||||
var m = x + 12
|
||||
|
||||
var y = int32(name)
|
||||
var n = y + 1
|
||||
|
||||
doAssert m == uint32(n + 11)
|
||||
|
||||
|
||||
foo()
|
||||
Reference in New Issue
Block a user