perl11 / potion

_why the lucky stiff's little language (the official repo... until _why returns)
http://groups.google.com/group/potion-lang
Other
661 stars 91 forks source link

Comparison between String and number does not work as expected #92

Closed robotii closed 8 years ago

robotii commented 8 years ago

"3" < 2 returns true

"3" number < 2 returns false

I would expect that the results of both would be false

When running with the bytecode interpreter I get an error:

bin/potion -B -I -e '"3" < 2' \ Invalid type String for reg[op.a], expected Number

It seems that the comparison is completely broken

rurban commented 8 years ago

The definition of brokenness is relative here. Comparing a string to a number is not defined. Only comparing a number to an int does auto type-coercion. Without typechecks it just compares the pointer to the value, with typecheck it correctly errors. The second example works as expected.