If YAML source contains the (standard) !!float tag, yaml fails with the message

The "!!float" handle wasn't declared.

In CHANGES, support for !!float is mentioned (0.2.2), but there is no composer for it. The above problem can easily be kludged away by stripping !!float tags, but it seems more correct to add support for them. Code and test diffs below.

Possible problem with this patch: the decision how to handle values that can't be converted to float using expr {double($value)} is above me. For the purposes of this patch my decision is to let the Tcl exception remain unhandled, so for the value 123_0 the error message is

expected floating-point number but got "123_0"

While this side-steps the error handling in yaml, it is still a clear and useful message and keeps the patch simple. The alternative is of course to catch it and rethrow using the module's error handling, but that is a bigger rewrite.

Code (yaml.tcl):

50d49
<             !!float ::yaml::_composeFloat
249,252d247
< }
<
< proc ::yaml::_composeFloat {value} {
<     return [list !!float [expr {double($value)}]]

Test (yaml.test):

769,785d768
< test yaml-21.1 "explicit_tags float" -body {
<     set y {!!float 123}
<     yaml::yaml2dict $y
< } -result {123.0}
<
<
< test yaml-21.2 "explicit_tags float" -body {
<     set y {!!float 123.0}
<     yaml::yaml2dict $y
< } -result {123.0}
<
<
< test yaml-21.2 "explicit_tags float" -body {
<     set y {!!float 123_0}
<     yaml::yaml2dict $y
< } -result {expected floating-point number but got "123_0"} -returnCodes error
<