Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* v0.4.6
- fix parsing of single runes, i.e. when doing ~defUnit(Ω•m⁻¹)~ the
parser would try to parse the Ω as a single ~char~ and not a unicode rune
* v0.4.5
- fix parsing of long unit names that are not in the unit table,
i.e. ~let x = 5.Foobar~, which would previously print the following
Expand Down
2 changes: 1 addition & 1 deletion src/unchained/parse_units.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ proc parsePrefixAndUnit(tab: UnitTable, x: string, start, stop: int):
doAssert false
of 1: # short unit without SI prefix
# must be short unit, e.g. `J`
result.unit = tab.getShort($x[start])
result.unit = tab.getShort($x.runeAt(start))
of 2:
# short unit with prefix (this means disallow long versions with length
# shorter than 3, unless we added a `isUpper` check
Expand Down
5 changes: 5 additions & 0 deletions tests/tunchained.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,11 @@ suite "Unchained - Bug issues":
type Foo = UnitLess
check 1.Foo * 1.Foo == 1.UnitLess

test "Define units with runes":
defUnit(Ω•m⁻¹)
let x = 5.Ω•m⁻¹
check typeof(x) is Ω•m⁻¹

suite "Utils":
test "Power w/ static integer exponents for floats":
let x = 5
Expand Down
Loading