Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean values get decoded as integers rather than as booleans #6

Closed
ghost opened this issue Feb 9, 2023 · 5 comments · Fixed by #7
Closed

Boolean values get decoded as integers rather than as booleans #6

ghost opened this issue Feb 9, 2023 · 5 comments · Fixed by #7

Comments

@ghost
Copy link

ghost commented Feb 9, 2023

local tomlStr = [[
a = 1275892
b = 'Hello, World!'
c = true
d = 124.2548

[e]
f = [ 1, 2, 3, '4', 5.142 ]
g = 1979-05-27
h = 07:32:00
i = 1979-05-27T07:32:00-07:00
]]

local succeeded, decoded_toml = pcall(toml.decode, tomlStr)

assert(decoded_toml.c == 1) -- succeeds (but shouldn't)
assert(decoded_toml.c == true) -- fails (but should succeed)

Install log:

❯ luarocks install toml
Installing https://luarocks.org/toml-0.1.1-0.src.rock

toml 0.1.1-0 depends on lua >= 5.1 (5.4-1 provided by VM)
Warning: unmatched variable LINK_FLAGS
Warning: unmatched variable LUA_LIBRARIES
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Cloning toml++
-- Cloning sol2
-- Cloning magic_enum
-- Performing Test COMPILER_SUPPORTS_ARCH_NATIVE
-- Performing Test COMPILER_SUPPORTS_ARCH_NATIVE - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sam/.tmp/luarocks_toml-0.1.1-0-4410119/toml.lua/build.luarocks
[ 16%] Building CXX object CMakeFiles/toml.lua.dir/src/toml.cpp.o
[ 33%] Building CXX object CMakeFiles/toml.lua.dir/src/decoding/decoding.cpp.o
[ 50%] Building CXX object CMakeFiles/toml.lua.dir/src/encoding/encoding.cpp.o
[ 66%] Building CXX object CMakeFiles/toml.lua.dir/src/DateAndTime/dateAndTime.cpp.o
[ 83%] Building CXX object CMakeFiles/toml.lua.dir/src/utilities/utilities.cpp.o
[100%] Linking CXX shared module toml.so
[100%] Built target toml.lua
[100%] Built target toml.lua
Install the project...
-- Install configuration: "Release"
-- Installing: /opt/homebrew/lib/luarocks/rocks-5.4/toml/0.1.1-0/lib/toml.so
toml 0.1.1-0 is now installed in /opt/homebrew (license: MIT)

Lua 5.4, macOS 12.4, using via Hammerspoon.

@LebJe
Copy link
Owner

LebJe commented Feb 10, 2023

Thanks for the report, this has been fixed in the next version, which will be released soon.

@ghost
Copy link
Author

ghost commented Feb 10, 2023

Great, thank you!

@marzer
Copy link

marzer commented Feb 10, 2023

@LebJe you may also want to update the embedded toml++; it's at v3.3.0 now and the last few releases have fixed a number of fun surprises I've discovered since the version currently used by this lib.

LebJe added a commit that referenced this issue Feb 12, 2023
* Added `terseKeyValuePairs` to the list of formatting options for `toml.encode`
* Tables can be made inline.
* `toml.decode` can decode date, time and date-time into userdata or plain tables.
* Use luaunit instead of busted for testing
* Boolean values are decoded as booleans instead of integers. (#6)
* Run tests on Windows
* Start preparing for TOMLInt (userdata type for formatted integers)
@LebJe LebJe mentioned this issue Feb 12, 2023
Merged
@LebJe LebJe linked a pull request Feb 12, 2023 that will close this issue
Merged
@LebJe LebJe closed this as completed in #7 Feb 12, 2023
LebJe added a commit that referenced this issue Feb 12, 2023
* Updated to toml++ v3.3.0
* Added `terseKeyValuePairs` to the list of formatting options for `toml.encode`
* Tables can be made inline.
* `toml.decode` can decode date, time and date-time into userdata or plain tables.
* Use luaunit instead of busted for testing
* Boolean values are decoded as booleans instead of integers. (#6)
* Run tests on Windows
* Start preparing for TOMLInt (userdata type for formatted integers)
* If `lua` is not available, use `luajit` (Linux CI)
* Update TOC
* Date, time and date-time should not be quoted by default.
* Update Changelog
@LebJe
Copy link
Owner

LebJe commented Feb 12, 2023

@SamuelSwartzberg 0.2.0 is released!

@ghost
Copy link
Author

ghost commented Feb 14, 2023

Nice, thanks again! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants