nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
177 stars 25 forks source link

Issues with Number.MIN_VALUE #39

Closed TomLavenziano closed 4 years ago

TomLavenziano commented 4 years ago

Expected behavior

Directly evaluating Number.MIN_VALUE should return the value 5e-324. Operating on Number.MIN_VALUE should return the correct result.

Actual behavior

Directly evaluating Number.MIN_VALUE instantly kills / exits the REPL process. No stacktrace or output is printed. This only occurs when evaluated directly, ie. console.log(Number.MIN_VALUE) prints correctly without exiting.

The automatic evaluation that prints as a comment on the same line before pressing enter still displays correctly (> Number.MIN_VALUE // 5e-324).

Performing addition, subtraction, and division operations on Number.MIN_VALUE returns incorrect results. Performing multiplication on Number.MIN_VALUE causes the REPL process to exit as well.

Concatenating a string with Number.MIN_VALUE does return the correct result without exiting.

This behavior only occurs with Number.MIN_VALUE, evaluating and operating on Number.MAX_VALUE returns correctly.

Steps to reproduce

Exit on evaluation:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE // 5e-324

$

Incorrect arithmetic results and exiting on multiplication:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE + 100 // 100
100
> Number.MIN_VALUE - 100 // -100
-100
> Number.MIN_VALUE / 100 // 0
0
> Number.MIN_VALUE * 100 // 4.94e-322

$

Correct evaluation when concatenating with a string:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE + 'Test' // '5e-324Test'
'5e-324Test'
devsnek commented 4 years ago

i can't reproduce the immediate exits. The arithmetic you posted is correct though