Fix contains? primitive to handle strings in both JS and Python
The JS contains? used `k in c` which throws TypeError on strings. The Python version silently returned False for strings. Both now use indexOf/`in` for substring matching on strings. Fixes: sx.js MOUNT PARSE ERROR on blog index where (contains? current-local-href "?") was evaluated client-side. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -196,6 +196,8 @@ def prim_is_empty(coll: Any) -> bool:
|
||||
|
||||
@register_primitive("contains?")
|
||||
def prim_contains(coll: Any, key: Any) -> bool:
|
||||
if isinstance(coll, str):
|
||||
return str(key) in coll
|
||||
if isinstance(coll, dict):
|
||||
k = key.name if isinstance(key, Keyword) else key
|
||||
return k in coll
|
||||
|
||||
Reference in New Issue
Block a user