Public repository: timo / feel

Reader

An interpreter of FEEL, written in Rust, with integrations for PostgreSQL, WASM, Lua, and Python.

fix(core): from-singleton-list unwraps exactly one level (§10.3.2.9.4)

public

fix(core): from-singleton-list unwraps exactly one level (§10.3.2.9.4)

The spec (Table 45) says: convert [e] → e by ONE level of unwrapping, then
apply the conforms-to check. The initial implementation used `coerce(items[0], t)`
which would have recursively unwrapped [[10]] all the way to 10 even when the
target type is `number`. The 0082 test `invoke_005` is the canonical case:
bkm_005([10]) → [[10]], coerced to number → null (not 10).

Replace the recursive call with a single-level unwrap + direct conformance check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Changeset7a63712efc9678ff4e429fa4557c5311573aca8c
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parents808a4610acbc
Children
Pushlog
by timo via ssh

modified crates/feel-core/src/types.rs +6 −1

@@ -120,10 +120,15 @@
120120
         return Value::Null;
121121
     }
122122
     // Rule 2: from-singleton-list — target is NOT a list, value IS a singleton.
123
+    // The spec (Table 45) converts `[e]` → `e` by ONE level of unwrapping, then
124
+    // applies the conforms-to check.  This is NOT recursive: `[[10]]` coerced to
125
+    // `number` yields null, not 10 (the inner `[10]` does not conform to number;
126
+    // `invoke_005` in 0082 is the canonical test for this).
123127
     if !matches!(t, FeelType::List(_)) {
124128
         if let Value::List(ref items) = v {
125129
             if items.len() == 1 {
126
-                return coerce(items[0].clone(), t);
130
+                let elem = items[0].clone();
131
+                return if value_conforms_to(&elem, t) { elem } else { Value::Null };
127132
             }
128133
         }
129134
     }