adobe / json-formula

Query language for JSON documents
http://opensource.adobe.com/json-formula/
Apache License 2.0
19 stars 8 forks source link

Inconsistent coercion #91

Closed JohnBrinkman closed 1 year ago

JohnBrinkman commented 1 year ago

The spec indicates that the conversion of objects and arrays to number are not supported:

array => string object => string array => number object => number object => array number => object string => object boolean => object

There are two inconsistencies:

  1. array => object should also not be supported.
  2. The implementation is inconsistent in handling implicit coercion:

{w:2} * 2 => 0 (with a warning) abs({w:2}) fails with: "TypeError: abs expected argument to be type number but received type object instead."

These should either both coerce to zero, or both fail. Recommend they both fail.

JohnBrinkman commented 1 year ago

Implemented