From 7304cf35f22eaee574b4a06e6d91284a01eed3cf Mon Sep 17 00:00:00 2001 From: Teakowa Date: Thu, 29 Oct 2026 18:23:35 +0800 Subject: [PATCH 1/3] fix(compiler): honor disabled optimizations for array indexing Lower index expressions through valueInArray and let the existing value optimizer choose firstOf only when optimizations are enabled. Add a pinned-oracle differential fixture covering integer and decimal zero indices, nonzero indices, and default/disabled/re-enabled optimization states. Fixes #672 --- crates/opy-rs/src/compiler/lowering/values.rs | 18 +++------- .../fixture.json | 24 +++++++++++++ .../structural-index-optimization/oracle.json | 34 +++++++++++++++++++ .../structural-index-optimization/source.opy | 22 ++++++++++++ 4 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/fixture.json create mode 100644 crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json create mode 100644 crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy diff --git a/crates/opy-rs/src/compiler/lowering/values.rs b/crates/opy-rs/src/compiler/lowering/values.rs index 850cce04..35b21d7a 100644 --- a/crates/opy-rs/src/compiler/lowering/values.rs +++ b/crates/opy-rs/src/compiler/lowering/values.rs @@ -218,21 +218,11 @@ impl<'a> Lowering<'a> { } return Ok(self.push_value(Value::Null)); } - // The pinned OverPy oracle lowers a literal zero-index read - // (`arr[0]`, `arr[0.0]`) to `firstOf(arr)`; non-zero indexes - // and indexed writes keep the indexed forms. let array = self.lower_value(array)?; - if matches!(index.as_ref(), Expr::Number { value, .. } if *value == 0.0) { - Value::Call { - name: "firstOf".to_string(), - args: vec![array], - } - } else { - let index = self.lower_value(index)?; - Value::Call { - name: "valueInArray".to_string(), - args: vec![array, index], - } + let index = self.lower_value(index)?; + Value::Call { + name: "valueInArray".to_string(), + args: vec![array, index], } } Expr::Format { text, args, .. } => { diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/fixture.json b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/fixture.json new file mode 100644 index 00000000..9b5086d6 --- /dev/null +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/fixture.json @@ -0,0 +1,24 @@ +{ + "schemaVersion": 1, + "id": "synthetic/structural-index-optimization", + "category": "compilation", + "features": [ + "structural convergence", + "array indexing", + "disableOptimizations" + ], + "source": "source.opy", + "tests": { + "source": { + "nativeStatus": "success", + "relationship": "match", + "ruleNames": true + }, + "compiler": { + "nativeStatus": "success", + "relationship": "match", + "comparison": "semantic-wir", + "semanticEquivalent": true + } + } +} diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json new file mode 100644 index 00000000..ba67e7f7 --- /dev/null +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json @@ -0,0 +1,34 @@ +{ + "compile": { + "diagnostics": [], + "exitCode": 0, + "status": "success", + "stdout": "", + "workshop": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n", + "workshopExact": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n", + "workshopSha256": "7735eca79ca4d512481d63ba1edfe9effa0ecd1bc77ab30c5142f908d5a2a363" + }, + "fixture": "synthetic/structural-index-optimization", + "input": { + "files": [ + { + "path": "source.opy", + "sha256": "6223155dced838a4c66dfe6d9ecec5c4ff539eb947ce5207dfb858df904e101d" + } + ], + "sha256": "89a909df7685cae7cba96b068b733a74ef11abc31631c60c5b9148be082c99a4", + "source": "source.opy" + }, + "oracle": { + "contentCommit": "5a7d0e294b8cad73b9701987bb584d0551d7fa4d", + "gitHead": "ec763c1d245aa5485ef61af5b2bda4975bce4877", + "integrity": "sha512-C5F6btT5yn19BvHuE0bjMuSd/2esebBabmpL4SYLQFuJ4IdouVOKEoMLLuJFAyNc0Phwrolblj5GDkDGYR0ofg==", + "language": "en-US", + "license": "GPL-3.0-only", + "name": "overpy", + "registryTarball": "https://registry.npmjs.org/overpy/-/overpy-9.7.17.tgz", + "repository": "https://github.com/Zezombye/overpy", + "version": "9.7.17" + }, + "schemaVersion": 1 +} diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy new file mode 100644 index 00000000..6cab9a57 --- /dev/null +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy @@ -0,0 +1,22 @@ +globalvar arr +globalvar result + +rule "enabled zero indexing": + @Event global + result = arr[0] + result = arr[0.0] + result = arr[1] + +#!disableOptimizations + +rule "disabled zero indexing": + @Event global + result = arr[0] + result = arr[0.0] + result = arr[1] + +#!enableOptimizations + +rule "reenabled zero indexing": + @Event global + result = arr[0] From ff50b54ea67ce75b825e6f6354930d162c1d4ce3 Mon Sep 17 00:00:00 2001 From: Teakowa Date: Thu, 29 Oct 2026 19:17:32 +0800 Subject: [PATCH 2/3] fix(compiler): preserve strict empty-array zero indexing (#672) --- crates/opy-rs/src/compiler/operator_optimization.rs | 8 ++------ .../structural-index-optimization/oracle.json | 10 +++++----- .../structural-index-optimization/source.opy | 11 +++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/opy-rs/src/compiler/operator_optimization.rs b/crates/opy-rs/src/compiler/operator_optimization.rs index 437db139..c62fe3ca 100644 --- a/crates/opy-rs/src/compiler/operator_optimization.rs +++ b/crates/opy-rs/src/compiler/operator_optimization.rs @@ -837,23 +837,19 @@ impl<'a> OperatorOptimizer<'a> { fn value_in_array(&self, args: Vec) -> Rewrite { let [array, index] = two(args); - let array = literal_array(array); + let mut array = literal_array(array); if let Value::Number(position) = index { if position < 0.0 { return Rewrite::Changed(Value::Null); } let position = position.round(); - if let Value::Array(mut elements) = array { + if let Value::Array(elements) = &mut array { if (position as usize) < elements.len() { return Rewrite::Changed(elements.swap_remove(position as usize)); } if !elements.is_empty() || !self.strict { return Rewrite::Changed(Value::Null); } - return Rewrite::Same(call( - "valueInArray", - vec![Value::Array(elements), Value::Number(position)], - )); } if position == 0.0 { return Rewrite::Changed(call("firstOf", vec![array])); diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json index ba67e7f7..ab30d2d3 100644 --- a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json @@ -4,19 +4,19 @@ "exitCode": 0, "status": "success", "stdout": "", - "workshop": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n", - "workshopExact": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n", - "workshopSha256": "7735eca79ca4d512481d63ba1edfe9effa0ecd1bc77ab30c5142f908d5a2a363" + "workshop": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n", + "workshopExact": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n", + "workshopSha256": "d0ddd79399a0b15d024cbbb67b113e0a9be157a3fdb1cb6847f95dbaa6f048da" }, "fixture": "synthetic/structural-index-optimization", "input": { "files": [ { "path": "source.opy", - "sha256": "6223155dced838a4c66dfe6d9ecec5c4ff539eb947ce5207dfb858df904e101d" + "sha256": "5d2892344747a1be74e80a1da52696d3d03a7bf68d572e1efd0d62a6177f80ea" } ], - "sha256": "89a909df7685cae7cba96b068b733a74ef11abc31631c60c5b9148be082c99a4", + "sha256": "ae1af22cf41de8a32feaedd470e0064ca5f5a67d1676bba31b37bd4361789e50", "source": "source.opy" }, "oracle": { diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy index 6cab9a57..ce1ead44 100644 --- a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy @@ -14,9 +14,20 @@ rule "disabled zero indexing": result = arr[0] result = arr[0.0] result = arr[1] + result = [][0] + result = [][0.0] + result = [][1] #!enableOptimizations rule "reenabled zero indexing": @Event global result = arr[0] + +#!optimizeStrict + +rule "strict empty array indexing": + @Event global + result = [][0] + result = [][0.0] + result = [][1] From 9bba1893a1109eda8b7928923c142da155e891b8 Mon Sep 17 00:00:00 2001 From: Teakowa Date: Thu, 29 Oct 2026 20:12:42 +0800 Subject: [PATCH 3/3] fix(compiler): preserve strict empty-array fractional indexes (#672) --- .../src/compiler/operator_optimization.rs | 35 +++++++++---------- .../structural-index-optimization/oracle.json | 10 +++--- .../structural-index-optimization/source.opy | 2 ++ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/crates/opy-rs/src/compiler/operator_optimization.rs b/crates/opy-rs/src/compiler/operator_optimization.rs index c62fe3ca..f41216e7 100644 --- a/crates/opy-rs/src/compiler/operator_optimization.rs +++ b/crates/opy-rs/src/compiler/operator_optimization.rs @@ -836,27 +836,26 @@ impl<'a> OperatorOptimizer<'a> { } fn value_in_array(&self, args: Vec) -> Rewrite { - let [array, index] = two(args); - let mut array = literal_array(array); - if let Value::Number(position) = index { - if position < 0.0 { - return Rewrite::Changed(Value::Null); - } - let position = position.round(); - if let Value::Array(elements) = &mut array { - if (position as usize) < elements.len() { - return Rewrite::Changed(elements.swap_remove(position as usize)); - } - if !elements.is_empty() || !self.strict { - return Rewrite::Changed(Value::Null); - } + let [mut array, index] = two(args); + array = literal_array(array); + let i = match (&array, index) { + (_, Value::Number(n)) if n < 0.0 => return Rewrite::Changed(Value::Null), + (Value::Array(items), Value::Number(n)) if self.strict && items.is_empty() => n, + (_, Value::Number(n)) => n.round(), + (_, index) => return Rewrite::Same(call("valueInArray", vec![array, index])), + }; + if let Value::Array(items) = &mut array { + if (i as usize) < items.len() { + return Rewrite::Changed(items.swap_remove(i as usize)); } - if position == 0.0 { - return Rewrite::Changed(call("firstOf", vec![array])); + if !items.is_empty() || !self.strict { + return Rewrite::Changed(Value::Null); } - return Rewrite::Same(call("valueInArray", vec![array, Value::Number(position)])); } - Rewrite::Same(call("valueInArray", vec![array, index])) + if i == 0.0 { + return Rewrite::Changed(call("firstOf", vec![array])); + } + Rewrite::Same(call("valueInArray", vec![array, Value::Number(i)])) } fn component(args: Vec, axis: usize) -> Rewrite { diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json index ab30d2d3..7017b52c 100644 --- a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/oracle.json @@ -4,19 +4,19 @@ "exitCode": 0, "status": "success", "stdout": "", - "workshop": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n", - "workshopExact": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n", - "workshopSha256": "d0ddd79399a0b15d024cbbb67b113e0a9be157a3fdb1cb6847f95dbaa6f048da" + "workshop": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0.1));\n Set Global Variable(result, Value In Array(Empty Array, 0.49));\n }\n}\n", + "workshopExact": "variables {\n global:\n 0: arr\n 1: result\n}\n\nrule (\"enabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, First Of(Global.arr));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n }\n}\n\n//Optimizations disabled\nrule (\"disabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, Value In Array(Global.arr, 0));\n Set Global Variable(result, Value In Array(Global.arr, 0.0));\n Set Global Variable(result, Value In Array(Global.arr, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0));\n Set Global Variable(result, Value In Array(Empty Array, 0.0));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n }\n}\n\n//Optimizations enabled\nrule (\"reenabled zero indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Global.arr));\n }\n}\n\n//Strict optimizations enabled\nrule (\"strict empty array indexing\") {\n event {\n Ongoing - Global;\n }\n actions {\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, First Of(Empty Array));\n Set Global Variable(result, Value In Array(Empty Array, 1));\n Set Global Variable(result, Value In Array(Empty Array, 0.1));\n Set Global Variable(result, Value In Array(Empty Array, 0.49));\n }\n}\n\n", + "workshopSha256": "4687610ab6d6c9e5c21d41595cf28d995c523e98c98ad1ed7834e8aa17bcea5d" }, "fixture": "synthetic/structural-index-optimization", "input": { "files": [ { "path": "source.opy", - "sha256": "5d2892344747a1be74e80a1da52696d3d03a7bf68d572e1efd0d62a6177f80ea" + "sha256": "314d849cbeb22cc56110be29a7881b36da2b36af0deaf6900a7ccc72b88b4ca4" } ], - "sha256": "ae1af22cf41de8a32feaedd470e0064ca5f5a67d1676bba31b37bd4361789e50", + "sha256": "52c63f2dab1e4c45a9bc6551a37fb9c78649a074d1e1ad8579160658e466dfb8", "source": "source.opy" }, "oracle": { diff --git a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy index ce1ead44..ecb49307 100644 --- a/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy +++ b/crates/opy-rs/tests/fixtures/corpus/synthetic/structural-index-optimization/source.opy @@ -31,3 +31,5 @@ rule "strict empty array indexing": result = [][0] result = [][0.0] result = [][1] + result = [][0.1] + result = [][0.49]