Skip to content

Commit a8502e4

Browse files
CrowdHailerlpil
authored andcommitted
cast inline table as a table
1 parent f373ab7 commit a8502e4

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## next
4+
5+
- Fixed bug where `InlineTable` could not be cast `as_table`.
6+
37
## v1.1.0 - 2024-09-23
48

59
- Added the `as_array`, `as_bool`, `as_date`, `as_date_time`, `as_float`,

src/tom.gleam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ pub fn as_array(toml: Toml) -> Result(List(Toml), GetError) {
15051505
pub fn as_table(toml: Toml) -> Result(Dict(String, Toml), GetError) {
15061506
case toml {
15071507
Table(tbl) -> Ok(tbl)
1508+
InlineTable(tbl) -> Ok(tbl)
15081509
other -> Error(WrongType([], "Table", classify(other)))
15091510
}
15101511
}

test/tom_test.gleam

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,9 @@ pub fn tom_as_table_test() {
10381038
tom.as_table(tom.Table(dict))
10391039
|> should.equal(Ok(dict))
10401040

1041+
tom.as_table(tom.InlineTable(dict))
1042+
|> should.equal(Ok(dict))
1043+
10411044
tom.as_table(tom.Int(1))
10421045
|> should.equal(Error(tom.WrongType([], "Table", "Int")))
10431046
}

0 commit comments

Comments
 (0)