json-formula icon indicating copy to clipboard operation
json-formula copied to clipboard

Undocumented type behavior for hidden properties in `value` and `hasProperty`

Open Eswcvlad opened this issue 1 year ago • 1 comments

Currently in the implementation of value and hasProperty, if there is a hidden property name in obj, type checking of arguments is ignored.

This is codified in these tests:

  • value(address.street, "$name")
  • hasProperty(address.street, "$name")

It seems logical, that it would work that way (though I would still check, that name is a string), but it contradicts the current spec documentation.

Eswcvlad avatar Jul 12 '24 21:07 Eswcvlad

I've updated the docs for value() and hasProperty(): https://github.com/adobe/json-formula/commit/4a9fd21a26123f179f166950a1ccc05b0858c5e4 I didn't bother to validate that the hidden property name was a string ... I suppose there's a very small chance that a non-string property parameter gets implicitly coerced to a hidden property name. But detecting that wasn't worth the extra code needed.

JohnBrinkman avatar Jul 16 '24 15:07 JohnBrinkman