VirtusLab / scala-yaml

https://virtuslab.github.io/scala-yaml/
Apache License 2.0
81 stars 22 forks source link

Hexadecimal values or `.inf` fails to get parsed #222

Open winitzki opened 1 year ago

winitzki commented 1 year ago

Yaml values such as 0xFFFF or -.inf are recognized as Integer and Double but parsing fails:

scala> println("0xFFFF".as[Int])
Left(ConstructError(Cannot parse 0xFFFF as Int
at 0:0, expected Int
0xFFFF
^ ))

scala> println("-.inf".as[Double])
Left(ConstructError(Cannot parse -.inf as Double
at 0:0, expected Double
-.inf
^ ))
lbialy commented 1 month ago

We use String#toIntOption and String#toDoubleOption to parse ints and doubles and these strings are not supported by those parsers. I guess to support them would mean writing a custom parser for both. Is this a part of yaml spec? Are those valid values for Int or Double by spec?

kpodsiad commented 1 month ago

@lbialy see https://yaml.org/spec/1.2.2/#core-schema and tag resolution