diff --git a/compiler/vm.nim b/compiler/vm.nim index d27f8136e0..ea29f040dc 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1363,7 +1363,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = else: internalError(c.config, c.debug[pc], "opcParseFloat: Incorrectly created openarray") else: - regs[ra].intVal = parseBiggestFloat(regs[ra].node.strVal, rcAddr.floatVal) + regs[ra].intVal = parseBiggestFloat(regs[rb].node.strVal, rcAddr.floatVal) of opcRangeChck: let rb = instr.regB diff --git a/tests/stdlib/tparseutils.nim b/tests/stdlib/tparseutils.nim index 0209644469..b699008646 100644 --- a/tests/stdlib/tparseutils.nim +++ b/tests/stdlib/tparseutils.nim @@ -99,3 +99,14 @@ block: # With this included, static: test() crashes the compiler (from a checkParseSize " 12" , 0, 1 # Leading white # Value Edge cases checkParseSize "9223372036854775807", 19, int64.high + +block: # bug #23936 + func parsePyFloat( + a: openArray[char], # here must be openArray instead of string to reproduce this bug + res: var BiggestFloat): int = + result = parseFloat(a, res) + + static: + var f = 0.0 + doAssert "1.0".parsePyFloat(f) == 3 + doAssert f == 1.0