Public repository: timo / feel

Reader

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

feat(core): range properties `.start` / `.end` / `.start included` / `.end included`

public

feat(core): range properties `.start` / `.end` / `.start included` / `.end included`

Add a `Value::Range` arm to `member_access` (DMN §10.3.2.6 / TCK 0074): the two
endpoint values and their inclusivity. `start included` / `end included` arrive as
single joined names (ADR-17), so they match directly; inclusivity is `!start_open`
/ `!end_open`. `start` / `end` clone the endpoint as stored, so an eventual unbounded
endpoint surfaces as its null without special-casing. An unknown property is a
value-null, mirroring `temporal::get_property` (a range has properties).

Completes the engine side of reverse-bracket interval support: `]1..10].start` and
`[1..10[.end included` now evaluate. Ingesting the TCK 0074 range cases is a
separate follow-up (the ingester still filters those expressions).

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

modified crates/feel-core/src/eval.rs +12 −0

@@ -836,6 +836,18 @@
836836
     match value {
837837
         Value::Context(map) => map.get(name).cloned().unwrap_or(Value::Null),
838838
         Value::Foreign(f) => f.0.get(name),
839
+        // Range properties (DMN §10.3.2.6 / TCK 0074): the two endpoint values and
840
+        // their inclusivity. `start included`/`end included` arrive as single joined
841
+        // names (ADR-17). `start`/`end` clone the endpoint as-is, so an (eventual)
842
+        // unbounded endpoint surfaces as its stored null. An unknown property is a
843
+        // value-null, mirroring `temporal::get_property` (a range *has* properties).
844
+        Value::Range(r) => match name {
845
+            "start" => r.start.clone(),
846
+            "end" => r.end.clone(),
847
+            "start included" => Value::Boolean(!r.start_open),
848
+            "end included" => Value::Boolean(!r.end_open),
849
+            _ => Value::Null,
850
+        },
839851
         v if temporal::is_temporal(&v) => temporal::get_property(&v, name),
840852
         _ => Value::Error,
841853
     }

modified crates/feel-core/src/lib.rs +20 −0

@@ -449,6 +449,26 @@
449449
         assert_eq!(ev("9 in [1..5+5["), b(true));
450450
         // Regression: a `[` after a completed value is still a filter subscript.
451451
         assert_eq!(ev("[10, 20, 30][2]"), num(20.0));
452
+    }
453
+
454
+    #[test]
455
+    fn range_properties() {
456
+        // The four range properties (DMN §10.3.2.6 / TCK 0074): endpoints + inclusivity.
457
+        assert_eq!(ev("[1..10].start"), num(1.0));
458
+        assert_eq!(ev("[1..10].end"), num(10.0));
459
+        assert_eq!(ev("[1..10].start included"), b(true));
460
+        assert_eq!(ev("[1..10].end included"), b(true));
461
+        // Openness flows through to `start/end included`, across every bracket form.
462
+        assert_eq!(ev("(1..10].start included"), b(false));
463
+        assert_eq!(ev("[1..10).end included"), b(false));
464
+        assert_eq!(ev("]1..10].start included"), b(false)); // reverse-open lower
465
+        assert_eq!(ev("[1..10[.end included"), b(false)); // reverse-close upper
466
+        assert_eq!(ev("]1..10].start"), num(1.0));
467
+        assert_eq!(ev("[1..10[.end"), num(10.0));
468
+        // Endpoints of any orderable type.
469
+        assert_eq!(ev(r#"["a".."c"].end"#), Value::String("c".into()));
470
+        // An unknown property of a range is a value-null (a range has properties).
471
+        assert_eq!(ev("[1..10].foo"), Value::Null);
452472
     }
453473
 
454474
     #[test]