From a05f18035654b93e84286693954178b9bd142462 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 22 Feb 2026 10:34:55 -0600 Subject: [PATCH] fix fuse bug --- CLAUDE.md | 2 +- mcode.cm | 22 ++-------------------- source/runtime.c | 2 ++ streamline.cm | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0e3d28a7..09615ebd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,7 +57,7 @@ The creator functions are **polymorphic** — behavior depends on argument types - `record(record, another)` — merge - `record(array_of_keys)` — create record from keys -Other key intrinsics: `length()`, `stone()`, `is_stone()`, `print()`, `filter()`, `find()`, `reduce()`, `sort()`, `reverse()`, `some()`, `every()`, `starts_with()`, `ends_with()`, `meme()`, `proto()`, `isa()`, `splat()`, `apply()`, `extract()`, `replace()`, `search()`, `format()`, `lower()`, `upper()`, `trim()` +Other key intrinsics: `object()`, `length()`, `stone()`, `is_stone()`, `filter()`, `find()`, `reduce()`, `sort()`, `reverse()`, `some()`, `every()`, `starts_with()`, `ends_with()`, `meme()`, `proto()`, `isa()`, `splat()`, `apply()`, `extract()`, `replace()`, `search()`, `format()`, `lower()`, `upper()`, `trim()` Sensory functions: `is_array()`, `is_text()`, `is_number()`, `is_object()`, `is_function()`, `is_null()`, `is_logical()`, `is_integer()`, `is_stone()`, etc. diff --git a/mcode.cm b/mcode.cm index 79a79996..84bdd570 100644 --- a/mcode.cm +++ b/mcode.cm @@ -878,7 +878,7 @@ var mcode = function(ast) { var inline_every = true var inline_some = true var inline_reduce = true - var inline_map = true + var inline_map = false var inline_find = true // --- Helper: emit arity-dispatched callback invocation --- @@ -2186,25 +2186,7 @@ var mcode = function(ast) { d = alloc_slot() return expand_inline_reduce(d, {arr: a0, fn: a1, init: a2, rev: a3}, nargs) } - // array(arr, fn) → inline map expansion - // Skip when first arg is a number literal (that's array(N, fn) — creation, not map) - if (nargs == 2 && fname == "array" && inline_map - && args_list[0].kind != "number") { - // Specialized: array(arr, known_sensory_intrinsic) → direct opcode loop - if (args_list[1].kind == "name" && args_list[1].intrinsic == true - && sensory_ops[args_list[1].name] != null) { - a0 = gen_expr(args_list[0], -1) - d = alloc_slot() - return expand_inline_map_intrinsic(d, a0, sensory_ops[args_list[1].name]) - } - // General: array(arr, fn_literal) → map loop with arity dispatch - if (args_list[1].kind == "function") { - a0 = gen_expr(args_list[0], -1) - a1 = gen_expr(args_list[1], -1) - d = alloc_slot() - return expand_inline_map(d, a0, a1) - } - } + // array(arr, fn) inline expansion removed — array() is too complex to inline } // Collect arg slots diff --git a/source/runtime.c b/source/runtime.c index 225aa691..94df3904 100644 --- a/source/runtime.c +++ b/source/runtime.c @@ -8550,6 +8550,8 @@ static JSValue js_cell_array (JSContext *ctx, JSValue this_val, int argc, JSValu /* array(object) - keys */ if (JS_IsRecord (arg)) { + if (argc > 1 && JS_IsFunction (argv[1])) + return JS_RaiseDisrupt (ctx, "array(record, fn) is not valid — use array(array(record), fn) to map over keys"); /* Return object keys */ return JS_GetOwnPropertyNames (ctx, arg); } diff --git a/streamline.cm b/streamline.cm index 5c37279a..b58b75a3 100644 --- a/streamline.cm +++ b/streamline.cm @@ -271,7 +271,7 @@ var streamline = function(ir, log) { shr: [2, T_INT, 3, T_INT], ushr: [2, T_INT, 3, T_INT], bitnot: [2, T_INT], concat: [2, T_TEXT, 3, T_TEXT], - not: [2, T_BOOL], and: [2, T_BOOL, 3, T_BOOL], or: [2, T_BOOL, 3, T_BOOL], + and: [2, T_BOOL, 3, T_BOOL], or: [2, T_BOOL, 3, T_BOOL], store_index: [1, T_ARRAY, 2, T_INT], store_field: [1, T_RECORD], push: [1, T_ARRAY], load_index: [2, T_ARRAY, 3, T_INT], load_field: [2, T_RECORD],