Open feluso opened 3 years ago
Thanks @feluso for pointing that out. HECTO and KILO should not be chained, in fact ICU4J (which is closely matched by the Unicode module here) defines in MeasureUnit.Complexity, that the recently declared MeasureUnit.MeasurePrefix must not apply to COMPOUND
units like meter-per-second, kilowatt-hour, kilogram-meter-per-square-second, etc.
We may impose similar constraints and checks because e.g. HECTO(KILOMETRE_PER_HOUR)
or even HECTO(KILOMETRE)
as mentioned here could both lead to similar problems. And while there currently is no exception thrown, chaining prefix operations either explicitly or implicitly (if you use an already prefixed unit) could be problematic.
So you came across 100 automatically being turned into HECTO
?
Seems related to #177
thanks for the explanation, that makes sense, the constraints seem appropiate, and regarding #177 while similar, this seems (as the replies suggest) that it's more over the fact they seem to be flipped, as noted in tech.units.indriya.AbstractUnit:406:
This test would fail with the following error:
Upon closer inspection using a debugger, we can see the values in
UCUMFormatParser
It seems the reason it fails it's because it parses
100
ash
fromHECTO
but as this was already akm
, the prefix only catches theh
and not thek
fromKILO
which causes it to be unable to recover them
unit from thesymbols
map, get anull
instead and throw aTokenException