wduquette / molt

Embeddable TCL Interpreter for Rust applications
BSD 3-Clause "New" or "Revised" License
103 stars 12 forks source link

Implicit Numeric Parsing fails on whitespace #28

Closed wduquette closed 5 years ago

wduquette commented 5 years ago

In molt, this code returns an error:

$ exit " 1 "
expected integer but got " 1 "
$

In Standard Tcl the command is accepted; and a look at Tcl_GetInt in Tcl 7.6 shows that it explicitly looks for and skips leading and trailing whitespace.

Molt uses Value::as_int to try to retrieve an integer from the argument; Value::as_int (and Interp::get_int, at time of writing) does not.

wduquette commented 5 years ago

Fixed by commit [46c512f3350a3458c43b4ece23fd8920c14cc3f3].