InvalidTomlNumberException when parsing hex literals containing 'e'
opened this issue · comments
Example
key = 0xdeadbeef
Exception thrown
Unhandled exception. Tomlet.Exceptions.InvalidTomlNumberException: While reading input line 1, found an invalid number literal '0xdeadbeef'
at Tomlet.TomlParser.ReadValue(StringReader reader) in D:\core\CSL\Tomlet\TomlParser.cs:line 235
at Tomlet.TomlParser.ReadKeyValuePair(StringReader reader, String& key, TomlValue& value) in D:\core\CSL\Tomlet\TomlParser.cs:line 108
The Problem
Line 233 in ReadValue
in TomlParser.cs
assumes a stringValue
with an "e" to be an exponential (1e06
) and fails on parse.
The Proposed Fix
replace
stringValue.Contains('e')
on line 233 in TomlParser.cs
with
(stringValue.Contains('e') && !stringValue.StartsWith("0x"))
to distinguish between exponentials and hex literals
Fixed in Tomlet 2.2.0, along with several other issues (both around number parsing and wider areas)