@calcit/procs 0.12.56 → 0.12.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/install-state.gz +0 -0
- package/RFCs/02-04-runtime-traits-plan.md +67 -573
- package/build.rs +36 -2
- package/editing-history/202608011759-issue-routing-in-agent-guide.md +17 -0
- package/editing-history/202608011833-schema-type-symbols.md +20 -0
- package/editing-history/202608011852-wasm-dynamic-string-tag.md +7 -0
- package/editing-history/202608011908-consolidate-history.md +6 -0
- package/editing-history/202608012022-consolidate-cli-and-test-duplication.md +28 -0
- package/editing-history/202608012123-review-follow-up.md +18 -0
- package/editing-history/202608012320-release-0.12.57.md +5 -0
- package/editing-history/202608012344-release-main-policy.md +5 -0
- package/editing-history/202608020058-data-api-and-trait-coverage.md +26 -0
- package/editing-history/ARCHIVE.md +15 -0
- package/editing-history/README.md +21 -0
- package/history/202608021153-runtime-traits.md +23 -0
- package/history/202608021227-format-markdown-cirru.md +18 -0
- package/history/202608021239-review-trait-followups.md +19 -0
- package/history/202608021251-defimpl-symbol-traits.md +8 -0
- package/history/202608021255-doc-type-symbols.md +6 -0
- package/history/202608021322-postfix-enum-methods.md +12 -0
- package/history/202608021327-postfix-unwrap-examples.md +10 -0
- package/history/202608021507-receiver-first-static-inference.md +21 -0
- package/history/202608021550-review-type-correctness.md +6 -0
- package/history/202608021730-release-0.12.58.md +5 -0
- package/lib/calcit.procs.d.mts +1 -0
- package/lib/calcit.procs.mjs +57 -47
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/calcit.procs.mts +62 -44
- package/editing-history/2026-02-13-1841-trait-origin-structural-eq.md +0 -91
- package/editing-history/2026-02-14-2050-js-codegen-recursion-tag-migration.md +0 -39
- package/editing-history/2026-02-14-2358-emit-js-modularization-shift-left.md +0 -63
- package/editing-history/2026-02-15-0000-diagnostics-consolidated.md +0 -35
- package/editing-history/2026-02-15-1941-macro-diagnostics-refinement.md +0 -39
- package/editing-history/2026-02-16-2043-core-api-docs-cleanup.md +0 -40
- package/editing-history/2026-02-23-0834-migrate-to-defstruct.md +0 -91
- package/editing-history/2026-02-23-2321-ns-imports-code-fixes.md +0 -42
- package/editing-history/2026-02-25-0002-language-behavior-eval-mode.md +0 -93
- package/editing-history/2026-02-25-0111-guidebook-no-check-block-upgrades.md +0 -52
- package/editing-history/2026-02-25-0113-runtime-type-validation-and-macro-quoting.md +0 -41
- package/editing-history/2026-02-25-1131-check-md-eval-improvements.md +0 -13
- package/editing-history/2026-02-26-1324-check-md-inprocess-cache-and-path-labels.md +0 -7
- package/editing-history/2026-02-27-1640-unify-markdown-readers.md +0 -16
- package/editing-history/2026-02-27-1958-tree-rewrite-command-and-reference-model.md +0 -18
- package/editing-history/2026-02-27-2200-split-def-command.md +0 -29
- package/editing-history/2026-02-27-2212-tree-raise-wrap.md +0 -33
- package/editing-history/2026-02-27-2223-calcit-agent-docs-optimize.md +0 -41
- package/editing-history/2026-03-01-0212-query-search-entry-and-ffi-warning.md +0 -53
- package/editing-history/2026-03-03-1934-check-types-and-core-annotations.md +0 -17
- package/editing-history/2026-03-04-0000-generics-fn-typevar-identity.md +0 -30
- package/editing-history/2026-03-04-1331-tag-call-warning-and-dot-access-migration.md +0 -28
- package/editing-history/2026-03-04-1548-impl-new-dot-method-input-and-doc-hints.md +0 -33
- package/editing-history/2026-03-04-1645-calcit-eq-contract-refactor-and-macro-tests.md +0 -28
- package/editing-history/2026-03-04-2200-assert-type-assert-traits-composable-runtime-checks.md +0 -18
- package/editing-history/2026-03-05-0042-type-inference-argtypes-and-core-hints.md +0 -54
- package/editing-history/2026-03-05-0115-calcit-core-generic-refinements.md +0 -57
- package/editing-history/2026-03-05-1930-schema-migration-cr-edit.md +0 -30
- package/editing-history/2026-03-05-1939-query-schema-adaptation.md +0 -42
- package/editing-history/2026-03-06-0120-schema-hint-migration-batch.md +0 -38
- package/editing-history/2026-03-06-1416-core-macro-schema-migration.md +0 -20
- package/editing-history/2026-03-06-1552-core-schema-and-hintfn-migration.md +0 -63
- package/editing-history/2026-03-06-1936-schema-normalization-and-preprocess-preload.md +0 -12
- package/editing-history/2026-03-07-0000-migrate-hint-fn-to-schema.md +0 -29
- package/editing-history/2026-03-07-0000-remove-enum-prototype-field.md +0 -43
- package/editing-history/2026-03-07-0000-schema-args-type-enforcement.md +0 -66
- package/editing-history/2026-03-07-0142-unit-type-and-builtin-schemas.md +0 -82
- package/editing-history/2026-03-07-1652-decouple-snapshot-schema-to-calcit-type.md +0 -112
- package/editing-history/2026-03-07-1821-snapshot-schema-validation.md +0 -6
- package/editing-history/2026-03-07-1959-schema-def-kind-arity-validation.md +0 -96
- package/editing-history/2026-03-08-0031-schema-generics-quote-normalization.md +0 -35
- package/editing-history/2026-03-08-1905-schema-typeref-and-assert-migration.md +0 -34
- package/editing-history/2026-03-08-2033-schema-wrapper-migration.md +0 -45
- package/editing-history/2026-03-08-2315-late-schema-cleanup-and-warning-compat.md +0 -27
- package/editing-history/2026-03-09-1753-schema-type-fail-tests.md +0 -17
- package/editing-history/2026-03-10-1040-edit-schema-primitive-tag-support.md +0 -42
- package/editing-history/2026-03-10-1754-ns-entry-snapshot-migration.md +0 -66
- package/editing-history/2026-03-13-2216-validate-struct-type-arg-arity.md +0 -24
- package/editing-history/2026-03-16-2353-runtime-boundary-cleanup.md +0 -14
- package/editing-history/2026-03-17-0150-runtime-boundary-lookup-cleanup.md +0 -28
- package/editing-history/2026-03-20-0116-json-builtins-and-runtime-docs.md +0 -48
- package/editing-history/2026-03-26-2013-docs-frontmatter-and-module-search.md +0 -58
- package/editing-history/2026-04-07-1550-path-format-at-prefix-migration.md +0 -46
- package/editing-history/2026-04-12-1524-js-codegen-map-to-record.md +0 -26
- package/editing-history/2026-04-12-1549-map-to-record-field-validation.md +0 -29
- package/editing-history/2026-04-13-1600-tuple-to-enum-rewrite.md +0 -13
- package/editing-history/2026-04-13-2309-typeslot-enum-compile-safety.md +0 -45
- package/editing-history/2026-04-14-1500-loose-record-syntax.md +0 -32
- package/editing-history/2026-04-14-2259-bidir-type-check-refactor.md +0 -63
- package/editing-history/2026-04-15-0120-match-syntax-exhaustiveness.md +0 -20
- package/editing-history/2026-04-15-1211-record-nth-optimization.md +0 -44
- package/editing-history/2026-04-16-1936-predicate-narrowing-expansion.md +0 -31
- package/editing-history/2026-04-17-0132-monomorphize-map-filter.md +0 -50
- package/editing-history/2026-04-17-0135-monomorphize-includes-reverse.md +0 -31
- package/editing-history/2026-04-17-0140-fold-type-predicates.md +0 -44
- package/editing-history/2026-04-17-0154-generic-dispatch-records-tuples.md +0 -52
- package/editing-history/2026-04-17-0520-simplify-generic-defns-via-method-dispatch.md +0 -49
- package/editing-history/2026-05-21-0055-tree-show-cr-config-and-edit-cleanup.md +0 -81
- package/editing-history/2026-05-31-2052-macro-schema-roundtrip-and-weak-types.md +0 -6
- package/editing-history/2026-05-31-2105-map-generic-weak-types-followup.md +0 -15
- package/editing-history/2026-06-01-0003-update-callback-field-specialization.md +0 -19
- package/editing-history/2026-06-01-2317-data-definition-where-bounds.md +0 -6
- package/editing-history/2026-06-02-0114-data-definition-where-macro-followup.md +0 -21
- package/editing-history/2026-06-03-0000-check-md-edn-errors.md +0 -5
- package/editing-history/2026-06-03-1600-check-md-entry-modules.md +0 -6
- package/editing-history/2026-06-04-0000-check-md-app-main-init.md +0 -6
- package/editing-history/2026-06-04-2218-compiled-executable-runtime-backfill.md +0 -6
- package/editing-history/2026-06-09-0000-with-type-slot-scoped-binding.md +0 -83
- package/editing-history/2026-06-09-1241-remove-bind-type.md +0 -64
- package/editing-history/2026-06-09-1800-core-effect-tags.md +0 -57
- package/editing-history/2026-06-10-1200-get-def-doc-schema-builtin.md +0 -7
- package/editing-history/2026-06-15-1500-effects-graph-mvp.md +0 -30
- package/editing-history/2026-06-16-1700-effects-graph-ste-tree.md +0 -84
- package/editing-history/2026-06-27-0052-cli-improvements.md +0 -41
- package/editing-history/2026-06-27-0202-docs-indexing-improvements.md +0 -22
- package/editing-history/2026-06-27-0315-file-splits.md +0 -17
- package/editing-history/2026-06-27-0416-agent-advanced-split.md +0 -15
- package/editing-history/archived/2025-04-12-1453-map-to-record-rewrite.md +0 -33
- package/editing-history/archived/2025-04-16-0117-wasm-codegen-and-catalog-update.md +0 -40
- package/editing-history/archived/2025-07-16-0207-wasm-encoder-migration.md +0 -48
- package/editing-history/archived/2025-07-16-1633-wasm-data-structures.md +0 -61
- package/editing-history/archived/2026-02-13-1926-docs-tests-followup.md +0 -33
- package/editing-history/archived/2026-02-16-2128-docs-smoke-and-trait-errors.md +0 -20
- package/editing-history/archived/2026-02-25-1234-watch-mode-default-once.md +0 -5
- package/editing-history/archived/2026-03-07-1302-calcit-agent-docs-update.md +0 -32
- package/editing-history/archived/2026-03-09-1819-add-test-fail-script.md +0 -5
- package/editing-history/archived/2026-03-09-1944-split-type-fail-tests.md +0 -8
- package/editing-history/archived/2026-03-16-1449-profiling-tools-reorg.md +0 -13
- package/editing-history/archived/2026-03-17-2026-afternoon-runtime-boundary-optimization-summary.md +0 -87
- package/editing-history/archived/2026-03-18-1802-tips-level-and-overwrite-schema-preservation.md +0 -26
- package/editing-history/archived/2026-03-20-1229-query-window-3-with-parent-preview.md +0 -72
- package/editing-history/archived/2026-03-23-1137-command-echo-tool-output-cleanup.md +0 -71
- package/editing-history/archived/2026-04-10-0011-snapshot-empty-version-pipe-marker.md +0 -23
- package/editing-history/archived/2026-04-16-0131-wasm-math-and-test-integration.md +0 -28
- package/editing-history/archived/2026-04-16-1507-wasm-data-structures-and-rfc-rename.md +0 -27
- package/editing-history/archived/2026-04-16-1520-wasm-bitwise-and-match.md +0 -21
- package/editing-history/archived/2026-04-16-1542-wasm-cross-ns-host-imports.md +0 -38
- package/editing-history/archived/2026-04-17-0026-wasm-rest-args.md +0 -62
- package/editing-history/archived/2026-04-17-0048-wasm-type-of.md +0 -70
- package/editing-history/archived/2026-04-17-0051-wasm-derived-predicates.md +0 -34
- package/editing-history/archived/2026-04-17-2316-wasm-do-println-fixes.md +0 -41
- package/editing-history/archived/2026-04-18-1208-split-emit-wasm-and-bump-version.md +0 -15
- package/editing-history/archived/2026-04-18-1430-wasm-list-match-and-method-dispatch.md +0 -5
- package/editing-history/archived/2026-04-18-2041-cr-wasm-split-and-runtime-stability.md +0 -18
- package/editing-history/archived/2026-04-18-2045-v0.12.23-ci-wasm-fix.md +0 -13
- package/editing-history/archived/2026-04-21-1818-wasm-string-ops-v2.md +0 -57
- package/editing-history/archived/2026-04-21-2332-split-emit-wasm.md +0 -45
- package/editing-history/archived/2026-04-22-0114-wasm-hof-intercepts-and-set-intersection.md +0 -82
- package/editing-history/archived/2026-04-22-0136-wasm-enum-tuple-bool-str-fixes.md +0 -68
- package/editing-history/archived/2026-04-22-1340-wasm-map-diff-new-and-let-intercept.md +0 -53
- package/editing-history/archived/2026-04-23-1419-v0.12.26-wasm-bisection-fixes.md +0 -7
- package/editing-history/archived/2026-04-23-1645-release-conventions.md +0 -14
- package/editing-history/archived/2026-04-25-1940-wasm-suite-multi-module-entry.md +0 -53
- package/editing-history/archived/2026-04-25-2003-wasm-method-includes-string-and-set-refactor.md +0 -71
- package/editing-history/archived/2026-04-25-2010-wasm-suite-add-fn-lens-edn.md +0 -43
- package/editing-history/archived/2026-04-25-2051-display-by.md +0 -39
- package/editing-history/archived/2026-04-28-1728-fix-gensym-stable.md +0 -31
- package/editing-history/archived/2026-04-29-1400-fix-bind-type-precompile.md +0 -38
- package/editing-history/archived/2026-05-26-0957-match-docs-check-md.md +0 -24
- package/editing-history/archived/2026-05-31-2059-ci-docs-test-and-fn-helper-tightening.md +0 -3
- package/editing-history/archived/2026-06-01-0005-release-0.12.36.md +0 -16
- package/editing-history/archived/2026-06-01-2230-enum-struct-payload-docs.md +0 -4
- package/editing-history/archived/2026-06-03-1620-release-0.12.38.md +0 -6
- package/editing-history/archived/2026-06-04-0000-release-0.12.39.md +0 -4
- package/editing-history/archived/2026-06-04-2230-release-0.12.40.md +0 -5
- package/editing-history/archived/2026-06-12-1525-weak-types-dots-format.md +0 -15
- package/editing-history/archived/2026-06-13-1200-primitive_schema_tags.md +0 -9
- package/editing-history/archived/2026-06-20-1142-ts-declaration-d-mts.md +0 -5
- package/editing-history/archived/2026-06-29-0117-upgrade-doc-snapshot-migration.md +0 -2
- package/editing-history/archived/2026-06-29-calcit-cli.md +0 -80
- package/editing-history/archived/2026-06-29-typed-calcit-cli-schemas.md +0 -23
- package/editing-history/archived/20260630-duplication-analysis.md +0 -116
package/build.rs
CHANGED
|
@@ -107,6 +107,41 @@ pub struct Snapshot {
|
|
|
107
107
|
pub files: HashMap<String, FileInSnapShot>,
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
fn parse_snapshot_entry(data: Edn) -> Result<SnapshotEntry, String> {
|
|
111
|
+
let map = data.view_map().map_err(|e| format!("entry must be a map: {e}"))?;
|
|
112
|
+
let ns_def = |key: &str| match map.get_or_nil(key) {
|
|
113
|
+
Edn::Str(text) | Edn::Symbol(text) => Ok(text.to_string()),
|
|
114
|
+
other => Err(format!(
|
|
115
|
+
"entry `:{key}` must be a namespace/definition string or symbol, got {other:?}"
|
|
116
|
+
)),
|
|
117
|
+
};
|
|
118
|
+
let mode = match map.get_or_nil("mode") {
|
|
119
|
+
Edn::Tag(tag) if tag.ref_str() == "native" => SnapshotRunMode::Native,
|
|
120
|
+
Edn::Tag(tag) if tag.ref_str() == "js" => SnapshotRunMode::Js,
|
|
121
|
+
Edn::Str(text) | Edn::Symbol(text) if text.trim_start_matches(':') == "native" => SnapshotRunMode::Native,
|
|
122
|
+
Edn::Str(text) | Edn::Symbol(text) if text.trim_start_matches(':') == "js" => SnapshotRunMode::Js,
|
|
123
|
+
other => return Err(format!("entry `:mode` must be :native or :js, got {other:?}")),
|
|
124
|
+
};
|
|
125
|
+
Ok(SnapshotEntry {
|
|
126
|
+
mode,
|
|
127
|
+
init_fn: ns_def("init-fn")?,
|
|
128
|
+
reload_fn: ns_def("reload-fn")?,
|
|
129
|
+
description: from_edn(map.get_or_nil("description")).map_err(|e| format!("entry `:description`: {e}"))?,
|
|
130
|
+
modules: from_edn(map.get_or_nil("modules")).map_err(|e| format!("entry `:modules`: {e}"))?,
|
|
131
|
+
type_slots: from_edn(map.get_or_nil("type-slots")).map_err(|e| format!("entry `:type-slots`: {e}"))?,
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fn parse_entries(data: Edn) -> Result<HashMap<String, SnapshotEntry>, String> {
|
|
136
|
+
let map = data.view_map().map_err(|e| format!("entries must be a map: {e}"))?;
|
|
137
|
+
let mut entries = HashMap::with_capacity(map.0.len());
|
|
138
|
+
for (name, value) in map.0 {
|
|
139
|
+
let name: String = from_edn(name).map_err(|e| format!("invalid entry name: {e}"))?;
|
|
140
|
+
entries.insert(name, parse_snapshot_entry(value)?);
|
|
141
|
+
}
|
|
142
|
+
Ok(entries)
|
|
143
|
+
}
|
|
144
|
+
|
|
110
145
|
fn format_edn_preview(value: &Edn) -> String {
|
|
111
146
|
let raw = cirru_edn::format(value, true).unwrap_or_else(|_| format!("{value:?}"));
|
|
112
147
|
const LIMIT: usize = 220;
|
|
@@ -479,8 +514,7 @@ fn main() {
|
|
|
479
514
|
Some(from_edn::<LegacySnapshotConfigs>(value).unwrap_or_else(|e| panic!("failed to parse calcit-core legacy `:configs`: {e}")))
|
|
480
515
|
}
|
|
481
516
|
};
|
|
482
|
-
let mut entries
|
|
483
|
-
from_edn(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
|
|
517
|
+
let mut entries = parse_entries(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
|
|
484
518
|
if let Some(configs) = &legacy_configs {
|
|
485
519
|
entries.insert(
|
|
486
520
|
"default".to_owned(),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Route discovered issues to their owning repository
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Add an Agent-guide rule requiring reproducible Calcit language, runtime, compiler, and CLI issues to be filed with their maintenance repository.
|
|
6
|
+
- Route module and library defects from their resolved local path to the library's own GitHub repository, rather than reporting them to the consuming project or Calcit core by default.
|
|
7
|
+
- Document explicit cross-repository issue creation with `gh issue create --repo OWNER/REPO`, target verification with `gh repo view`, evidence requirements, and safe handling of sensitive reproduction data.
|
|
8
|
+
|
|
9
|
+
## Validation
|
|
10
|
+
|
|
11
|
+
- Confirmed `gh issue create --help` exposes `--repo [HOST/]OWNER/REPO` for selecting another repository.
|
|
12
|
+
- Confirmed the current GitHub CLI authentication can query the non-current `calcit-lang/setup-cr` repository.
|
|
13
|
+
- `cargo build --bin cr`
|
|
14
|
+
- `cargo test --bin cr agents_docs_default_to_the_version_matched_embedded_guide`
|
|
15
|
+
- `./target/debug/cr docs check-md docs/CalcitAgent.md --entry calcit/test.cirru --failures-only`
|
|
16
|
+
- `./target/debug/cr docs graph check`
|
|
17
|
+
- `git diff --check`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Canonical schema types use quoted symbols
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Keep legacy lowercase type tags load-compatible, while making quoted symbols such as `'String`, `'List`, `'Fn`, and `'Dynamic` the canonical schema serialization.
|
|
6
|
+
- Make `cr edit format` rewrite only recognized type positions in schemas, hints, assertions, coercions, structs, and enums; ordinary tag data remains unchanged.
|
|
7
|
+
- Migrate repository Snapshots, type-query/IR/agent-interface output, build-time core Snapshot loading, and primary type documentation.
|
|
8
|
+
|
|
9
|
+
## Validation
|
|
10
|
+
|
|
11
|
+
- `cargo fmt`
|
|
12
|
+
- `cargo test`
|
|
13
|
+
- `cargo clippy -- -D warnings`
|
|
14
|
+
- `yarn compile`
|
|
15
|
+
- `yarn check-all`
|
|
16
|
+
- `yarn check-agent-interface`
|
|
17
|
+
- `cr docs check-md docs/features/static-analysis.md --entry calcit/test.cirru --failures-only`
|
|
18
|
+
- `cr docs check-md docs/CalcitAgent.md --entry calcit/test.cirru --failures-only`
|
|
19
|
+
- `cr docs graph check`
|
|
20
|
+
- formatted every valid repository Snapshot with `cr edit format`, then `cr calcit/test.cirru --check-only`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# WASM dynamic string tag
|
|
2
|
+
|
|
3
|
+
- Schema type migration removed legacy type tags from program data, which can shift WASM's program-local tag indices.
|
|
4
|
+
- The Node.js WASM test host must not assume that the `string` type tag always has index 34.
|
|
5
|
+
- Export the generated module's actual string tag as `__string_tag` and use that value when the host validates or allocates strings.
|
|
6
|
+
- Keep the test host compatible with older generated modules by recovering the tag from their static string pool when the export is absent.
|
|
7
|
+
- Regression command: `cargo build --bin cr-wasm && CR_WASM_BIN=./target/debug/cr-wasm bash scripts/test-wasm.sh`.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Consolidate historical editing notes
|
|
2
|
+
|
|
3
|
+
- Replaced 142 individual notes from June 2026 and earlier with a compact topic index.
|
|
4
|
+
- Retained all July–August notes for active maintenance context.
|
|
5
|
+
- The removed notes remain recoverable through Git history; `editing-history/README.md` documents the retention rule.
|
|
6
|
+
- Verification: reviewed the tracked path set and checked the resulting Git diff.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Consolidate CLI and test duplication
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Introduced a typed `TreeOperation` model and shared cursor path transforms so edit, tree, and cursor commands use one implementation for structural mutations.
|
|
6
|
+
- Reused one staged-file abstraction for atomic cursor writes and edit transactions, including permission preservation, sync, commit, and cleanup behavior.
|
|
7
|
+
- Consolidated query result collection/rendering and type-coverage scope traversal without changing their JSON envelopes or diagnostics.
|
|
8
|
+
- Added one test-only temporary project fixture shared by edit, cursor, and query tests.
|
|
9
|
+
- Replaced eight identical Calcit test-local `log-title` definitions with `util.core/log-title`, keeping each standalone snapshot loadable through its module configuration.
|
|
10
|
+
- Removed the misspelled `test-gynienic.cirru` snapshot because the typed `test-hygienic.cirru` suite is a strict superset, and removed the identical `test-cond` runtime case from the macro suite.
|
|
11
|
+
- Made the remaining `case-default` macroexpansion assertion deterministic by resetting the gensym counter before checking the generated symbol.
|
|
12
|
+
|
|
13
|
+
## Review notes
|
|
14
|
+
|
|
15
|
+
- Kept repeated `main!` and `reload!` definitions because they are snapshot entry points rather than interchangeable helpers.
|
|
16
|
+
- Kept similarly named macro, native, JS, and WASM tests when they exercise different expansion or backend behavior.
|
|
17
|
+
- The resulting tracked diff removes more code than it adds while retaining the command boundaries and test coverage.
|
|
18
|
+
|
|
19
|
+
## Validation
|
|
20
|
+
|
|
21
|
+
- `cargo fmt`
|
|
22
|
+
- `cargo clippy -- -D warnings`
|
|
23
|
+
- `cargo test`
|
|
24
|
+
- `yarn compile`
|
|
25
|
+
- `yarn check-agent-interface` (12/12 scenarios)
|
|
26
|
+
- `yarn check-all` (native, JS, and WASM)
|
|
27
|
+
- Standalone native runs for the updated Calcit snapshots, including `test-cond.cirru`, `test-macro.cirru`, and `test-hygienic.cirru`
|
|
28
|
+
- Real-project Respo regression with JSON definition query and summary-only type-coverage analysis
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Review follow-up for CLI consolidation
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- Updated staged-file rewriting to open the temporary file with write access, truncate it, write through the same handle, and then sync it. This keeps `sync_all` valid on Windows.
|
|
6
|
+
- Reject symbolic-link destinations before staging so an atomic rename cannot silently replace the link while preserving permissions from its target.
|
|
7
|
+
- Avoid copying every definition tree during whole-project search; only a subtree selected by `--start-path` remains owned.
|
|
8
|
+
- Corrected cursor feedback so replace, swap, unwrap, and wrap report an unaffected cursor when their path did not change.
|
|
9
|
+
|
|
10
|
+
## Tests
|
|
11
|
+
|
|
12
|
+
- Added staged write/commit coverage and a Unix symbolic-link rejection test.
|
|
13
|
+
- Added cursor feedback assertions for unrelated paths and single-child unwraps.
|
|
14
|
+
|
|
15
|
+
## Review disposition
|
|
16
|
+
|
|
17
|
+
- Kept the existing parent-context preview for `query search-expr`; it predates this refactor and is intentional shared search presentation rather than a regression.
|
|
18
|
+
- Deferred directory `fsync` after rename: it is a larger crash-durability policy decision, especially for multi-file commits, and is not needed to correct the current atomic rename behavior.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Release 0.12.57
|
|
2
|
+
|
|
3
|
+
- Release the merged CLI mutation, atomic staging, and test deduplication work from PR #284.
|
|
4
|
+
- Include the follow-up fixes for Windows staged-file synchronization, symlink destinations, query cloning, and cursor feedback.
|
|
5
|
+
- Synchronize the Rust crate and npm package versions, then refresh the workspace lockfile before publishing.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Release main-branch policy
|
|
2
|
+
|
|
3
|
+
- Main no longer requires pull-request protection for verified changes.
|
|
4
|
+
- The release flow now requires the stable version commit to be on `main`, followed by a fresh main-branch CI run before tagging and creating the release.
|
|
5
|
+
- Corrected the npm verification command to use the published package name, `@calcit/procs`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Data API and trait coverage
|
|
2
|
+
|
|
3
|
+
## Review outcome
|
|
4
|
+
|
|
5
|
+
- Corrected the core `Option` and `Result` declarations to carry their real generic parameters instead of dynamic payloads.
|
|
6
|
+
- Added the missing high-frequency predicate, fallback, chaining, and error-mapping helpers, with schemas, method bags, docs, and queryable examples.
|
|
7
|
+
- Added the documented-but-missing `Compare` trait for Number and String.
|
|
8
|
+
- Connected the existing `Countable` and `Contains` traits to List, Map, Set, String, Record, and Tuple/enum values for method dispatch, static `:where` checks, and runtime `assert-traits`.
|
|
9
|
+
|
|
10
|
+
## Cross-platform consistency
|
|
11
|
+
|
|
12
|
+
- Made Number and String `.compare` visible through the shared built-in method bags so native, JavaScript, and WASM preprocessing agree.
|
|
13
|
+
- Aligned Rust and JavaScript trait introspection for Record/Struct and Tuple/Enum by merging their built-in and attached impl records.
|
|
14
|
+
- Added native, JavaScript, and WASM regression coverage for the new APIs and trait capabilities.
|
|
15
|
+
|
|
16
|
+
## Type-system fix
|
|
17
|
+
|
|
18
|
+
- Named generic enum values now safely satisfy builtin dynamic-tuple parameters, while a dynamic tuple still cannot satisfy a concrete named enum.
|
|
19
|
+
- Type-definition resolution now unwraps `def` and `impl-traits` and resolves unqualified core enum references.
|
|
20
|
+
- Tracked the underlying generic-enum diagnostic defect in <https://github.com/calcit-lang/calcit/issues/287>.
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
|
|
24
|
+
- Expanded the data-type overview to distinguish persistent values, named data, executable values, and explicitly stateful containers.
|
|
25
|
+
- Documented Cirru EDN versus JSON fidelity, unsupported values, and restoring declared Record/Enum identity during parsing.
|
|
26
|
+
- Added the built-in trait matrix and the Option/Result helper surface to the polymorphism guide.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Consolidated history through June 2026
|
|
2
|
+
|
|
3
|
+
Detailed task notes before July 2026 were consolidated on 2026-08-01. Their
|
|
4
|
+
full text remains recoverable from Git history; this file preserves the useful
|
|
5
|
+
navigation layer.
|
|
6
|
+
|
|
7
|
+
| Period | Durable themes |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 2025–Feb 2026 | WASM/codegen groundwork, structural equality, diagnostics, core API documentation, and migration toward `defstruct`. |
|
|
10
|
+
| Mar 2026 | Schema and type-annotation redesign: `hint-fn` migration, schema normalization/validation, generic type references, arity checks, and type-fail coverage. |
|
|
11
|
+
| Apr 2026 | Records/enums, type narrowing and generic dispatch; the WASM runtime gained collections, strings, methods, host imports, and multi-module tests. |
|
|
12
|
+
| May–Jun 2026 | Weak-type analysis, data-definition bounds, markdown checking, compiled-runtime backfill, scoped type slots, effects graph, and Agent/CLI documentation. |
|
|
13
|
+
|
|
14
|
+
For current behavior, prefer `docs/`, tests, and the retained July–August notes
|
|
15
|
+
over this summary.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Editing history
|
|
2
|
+
|
|
3
|
+
This directory keeps short, task-specific notes that help with nearby follow-up
|
|
4
|
+
work. It is not a second changelog: exact prior notes remain available from Git
|
|
5
|
+
history after they leave this directory.
|
|
6
|
+
|
|
7
|
+
## Retention
|
|
8
|
+
|
|
9
|
+
- Keep individual notes for the current development window (normally the most
|
|
10
|
+
recent 45 days).
|
|
11
|
+
- Periodically replace older clusters with a concise topic summary in
|
|
12
|
+
[ARCHIVE.md](ARCHIVE.md), then remove their individual files.
|
|
13
|
+
- Each code commit still adds one timestamped note, but it should capture only
|
|
14
|
+
durable context: the reason for the change, compatibility constraints, and
|
|
15
|
+
the relevant verification command.
|
|
16
|
+
|
|
17
|
+
To recover a removed note, search the repository history, for example:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git log --all -- editing-history/
|
|
21
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Runtime traits: nominal implementations
|
|
2
|
+
|
|
3
|
+
## What changed
|
|
4
|
+
|
|
5
|
+
- Runtime `CalcitTrait` values now have nominal identity, so independently evaluated traits with the same displayed name and method shape do not match accidentally.
|
|
6
|
+
- Concrete `defimpl` values carry their exact trait origin, require the complete declared method set, and reject non-callable methods. Native preprocessing additionally verifies signatures when metadata is available.
|
|
7
|
+
- Tag-based `defimpl` remains compatible as an originless inherent method bag. It continues to support ordinary `.method` dispatch, but cannot satisfy trait bounds, `assert-traits`, or `&trait-call`.
|
|
8
|
+
- Core builtin capability implementations now preserve trait origins in native and JS runtimes, including scalar values. WASM remains an internal validation backend and reports an explicit unsupported-runtime-trait error when preprocessing cannot eliminate trait operations.
|
|
9
|
+
- `cr edit format` emits a non-blocking migration advisory for legacy tag-based trait arguments.
|
|
10
|
+
|
|
11
|
+
## Verification
|
|
12
|
+
|
|
13
|
+
- `cargo fmt --check`
|
|
14
|
+
- `cargo clippy -- -D warnings`
|
|
15
|
+
- `cargo test` (298 library tests, 176 CLI tests)
|
|
16
|
+
- `yarn compile`
|
|
17
|
+
- `yarn check-all` (Agent interface, native, JS, IR, and WASM)
|
|
18
|
+
- `cr docs check-md` for traits, polymorphism, and upgrade documentation; all 24 Cirru blocks round-trip through the current formatter.
|
|
19
|
+
- External Respo check-only, type summary, and targeted example regression.
|
|
20
|
+
|
|
21
|
+
## Compatibility
|
|
22
|
+
|
|
23
|
+
This intentionally tightens concrete trait implementation validation. Existing tag-based method bags keep running, with a migration advisory. Code that treated unrelated same-named or partial implementations as satisfying a trait must migrate to a real `deftrait` plus complete nominal `defimpl`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Markdown Cirru formatter
|
|
2
|
+
|
|
3
|
+
## What changed
|
|
4
|
+
|
|
5
|
+
- Added `cr docs format-md <file>` to canonicalize fenced `cirru`, `cirru.no-run`, `cirru.no-check`, and `cirru.cli` blocks in Markdown.
|
|
6
|
+
- Added `--check` for CI: it reports non-canonical blocks without writing the Markdown file.
|
|
7
|
+
- Formatting preserves non-Cirru Markdown and fence labels, parses code directly as multiple Cirru AST roots, and writes using the existing atomic replacement helper.
|
|
8
|
+
- Added CLI help, command-echo support, unit coverage for formatting, parse errors, idempotence, and the non-writing check mode.
|
|
9
|
+
- Documented usage in CLI options and library quality guidance.
|
|
10
|
+
|
|
11
|
+
## Verification
|
|
12
|
+
|
|
13
|
+
- `cargo fmt --check`
|
|
14
|
+
- `cargo clippy -- -D warnings`
|
|
15
|
+
- `cargo test`
|
|
16
|
+
- `yarn compile`
|
|
17
|
+
- `yarn check-all`
|
|
18
|
+
- `cr docs format-md --check` and `cr docs check-md` on affected documentation.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Trait review follow-ups
|
|
2
|
+
|
|
3
|
+
## What changed
|
|
4
|
+
|
|
5
|
+
- Corrected the public `Mappable` capability table: Result joins List, Map, Set, and Option.
|
|
6
|
+
- Documented why `calcit.internal` is excluded from the legacy inherent-impl advisory: bootstrap method bags precede public nominal trait availability.
|
|
7
|
+
- Made builtin literal method introspection tolerant of unavailable core impl lists, matching record and tuple behavior in embedding/unit-test startup states.
|
|
8
|
+
- Corrected `&str:contains?` documentation and schema to describe numeric character-index bounds checking; substring membership remains `&str:includes?`.
|
|
9
|
+
- Restrict primitive trait-name bootstrap fallback to the period before its real core impl list is evaluated, and added a test that reads the embedded core Snapshot to detect table drift.
|
|
10
|
+
|
|
11
|
+
## Verification
|
|
12
|
+
|
|
13
|
+
- `cr src/cirru/calcit-core.cirru edit format`
|
|
14
|
+
- `cargo fmt --check`
|
|
15
|
+
- `cargo clippy -- -D warnings`
|
|
16
|
+
- `cargo test` (300 library tests, 179 CLI tests)
|
|
17
|
+
- `yarn compile`
|
|
18
|
+
- `yarn check-all` (Agent interface, native, JS, IR, WASM)
|
|
19
|
+
- `cr docs check-md --entry calcit/test.cirru docs/features/polymorphism.md`
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# `defimpl` trait arguments use raw symbols
|
|
2
|
+
|
|
3
|
+
- Migrated ordinary test fixtures from tag-based `defimpl` trait arguments to named `deftrait` values referenced directly as symbols.
|
|
4
|
+
- Kept the new trait definitions' entry schemas as `'Trait`, so the snapshot metadata matches their runtime role.
|
|
5
|
+
- Updated the `defimpl` macro documentation and diagnostics: raw symbols are the standard syntax; tag arguments remain only as legacy inherent-method-bag compatibility.
|
|
6
|
+
- Updated the tuple test to assert the new nominal trait origin rather than the old tag representation.
|
|
7
|
+
|
|
8
|
+
`&impl::new :name` bootstrap method bags are intentionally unchanged: unlike the macro form, a raw symbol there would be evaluated rather than captured as syntax.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Documentation type syntax audit
|
|
2
|
+
|
|
3
|
+
- Updated the trait guide and quick reference so schema and data-declaration type positions use quoted symbols (`'String`, `'Number`, `'Fn`, and so on).
|
|
4
|
+
- Kept ordinary tag data unchanged, including enum variants, record keys, and schema-map keys such as `:return`.
|
|
5
|
+
- Ran `docs format-md` and `docs check-md` with `calcit/test.cirru` for both updated guides.
|
|
6
|
+
- The wider audit still finds legacy type-tag examples in feature, run, and migration pages. Upgrade/compatibility explanations deliberately retain old spellings; the remaining tutorial/reference pages should be migrated in a dedicated documentation sweep with code-block validation.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Receiver-first enum method calls
|
|
2
|
+
|
|
3
|
+
- Extended preprocess-time postfix method rewriting to recognize nominal enum
|
|
4
|
+
receivers as well as records and traits.
|
|
5
|
+
- During core bootstrapping, infer the declared result type of `%some`, `%none`,
|
|
6
|
+
`%ok`, and `%err` from their schemas, so their values keep enough type
|
|
7
|
+
information for receiver-first calls such as `res-ok .unwrap-or 9`.
|
|
8
|
+
- Updated Option/Result trait tests and polymorphism documentation to use the
|
|
9
|
+
receiver-first form, and verified the JavaScript backend emits normal method
|
|
10
|
+
invocation code.
|
|
11
|
+
- Updated a formatting-advisory fixture assertion whose legacy inherent-impl
|
|
12
|
+
warning was intentionally removed by the earlier symbol-type migration.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Receiver-first unwrap examples
|
|
2
|
+
|
|
3
|
+
- Migrated the built-in `option:unwrap-or` and `result:unwrap-or` API examples
|
|
4
|
+
to the typed receiver-first method form.
|
|
5
|
+
- Verified the examples through `analyze check-examples`, the Markdown snippet
|
|
6
|
+
through `docs check-md`, and generated JavaScript by executing the trait test
|
|
7
|
+
bundle with Node.js.
|
|
8
|
+
- Kept the two WASM fixtures in function form: the internal WASM backend does
|
|
9
|
+
not yet lower enum constructor receiver-method calls, while its complete
|
|
10
|
+
verification suite continues to pass with the supported form.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Receiver-first calls with stronger static inference
|
|
2
|
+
|
|
3
|
+
- Extended receiver-first rewriting from Result/Option to every receiver whose
|
|
4
|
+
static method table is known, including built-in collections, primitives,
|
|
5
|
+
traits, structs, records, and enums. Prefix calls remain compatible.
|
|
6
|
+
- Preserved concrete `deftrait`, `defimpl`, `defstruct`, and `defenum` metadata
|
|
7
|
+
through local bindings and imported definitions, so `impl-traits` no longer
|
|
8
|
+
collapses nominal values to `Dynamic` or a broad `Custom` type.
|
|
9
|
+
- Propagated generic `:where` capabilities into function bodies and enum
|
|
10
|
+
`match` payloads, including lexical data definitions and nested named type
|
|
11
|
+
references. `%::` now retains enum identity even when a payload-free variant
|
|
12
|
+
cannot determine every generic argument.
|
|
13
|
+
- Inferred typed trait-method returns, required struct fields read through
|
|
14
|
+
`get`, and body-hinted parameter types. Broad `assert-type` checks no longer
|
|
15
|
+
erase a more precise compatible inferred type.
|
|
16
|
+
- Migrated representative Calcit snapshots and Markdown examples to
|
|
17
|
+
receiver-first syntax, formatted every touched Cirru block, and executed the
|
|
18
|
+
documented outputs on native and JavaScript targets.
|
|
19
|
+
- Kept conservative `Dynamic` fallback for opaque FFI values, heterogeneous or
|
|
20
|
+
genuinely unresolved nested data, and metadata that cannot be resolved
|
|
21
|
+
without executing arbitrary user code.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Review type-correctness follow-ups
|
|
2
|
+
|
|
3
|
+
- Kept named enum compatibility directional: a resolved enum `TypeRef` may satisfy a dynamic tuple parameter, but a dynamic tuple may not satisfy the named enum.
|
|
4
|
+
- Added namespace-qualified source identity to pre-runtime trait references so bootstrap fallback cannot confuse a user trait with a same-named core trait.
|
|
5
|
+
- Let unresolved core Option/Result constructors fall through to schema inference and taught method return inference to read impl methods from resolved enum `TypeRef` values.
|
|
6
|
+
- Added regressions for nominal trait fallback, source trait identity, and chained receiver-first Option/Result calls.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Release 0.12.58
|
|
2
|
+
|
|
3
|
+
- Release the receiver-first method inference and trait nominal-identity fixes merged in PR #288.
|
|
4
|
+
- Synchronize the crate, npm package, and Cargo lockfile versions at `0.12.58`.
|
|
5
|
+
- The merge commit passed the main Test and CodeQL workflows before this release commit.
|
package/lib/calcit.procs.d.mts
CHANGED
|
@@ -266,6 +266,7 @@ declare let calcit_builtin_impls: {
|
|
|
266
266
|
fn: CalcitImplEntry;
|
|
267
267
|
tuple: CalcitImplEntry;
|
|
268
268
|
record: CalcitImplEntry;
|
|
269
|
+
scalar: CalcitImplEntry;
|
|
269
270
|
};
|
|
270
271
|
export declare let register_calcit_builtin_impls: (options: typeof calcit_builtin_impls) => void;
|
|
271
272
|
/** method used as closure */
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -176,47 +176,27 @@ export let _$n_assert_traits = function (value, traitDef) {
|
|
|
176
176
|
if (!(traitDef instanceof CalcitTrait)) {
|
|
177
177
|
throw new Error(`&assert-traits expected a trait definition, but received: ${toString(traitDef, true)}`);
|
|
178
178
|
}
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
else if (value instanceof CalcitTuple) {
|
|
186
|
-
impls = value.impls ?? [];
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
const pair = lookup_impls(value);
|
|
190
|
-
if (pair == null) {
|
|
191
|
-
throw new Error(`&assert-traits cannot resolve impls for: ${toString(value, true)}`);
|
|
192
|
-
}
|
|
193
|
-
impls = pair[0];
|
|
194
|
-
}
|
|
195
|
-
const missing = [];
|
|
196
|
-
for (let i = 0; i < traitDef.methods.length; i++) {
|
|
197
|
-
const method = traitDef.methods[i];
|
|
198
|
-
let exists = false;
|
|
199
|
-
for (let j = 0; j < impls.length; j++) {
|
|
200
|
-
const impl = impls[j];
|
|
201
|
-
if (impl != null && impl.getOrNil(method) != null) {
|
|
202
|
-
exists = true;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (!exists)
|
|
207
|
-
missing.push(method.toString());
|
|
179
|
+
// Use the same merged builtin + attached impl list as method dispatch.
|
|
180
|
+
// Otherwise records and tuples can call a builtin method while
|
|
181
|
+
// `assert-traits` incorrectly claims that the corresponding trait is absent.
|
|
182
|
+
const pair = lookup_impls(value);
|
|
183
|
+
if (pair == null) {
|
|
184
|
+
throw new Error(`&assert-traits cannot resolve impls for: ${toString(value, true)}`);
|
|
208
185
|
}
|
|
186
|
+
const impls = pair[0];
|
|
187
|
+
const reverse = value instanceof CalcitRecord || value instanceof CalcitTuple || value instanceof CalcitStruct || value instanceof CalcitEnum;
|
|
188
|
+
const ordered = reverse ? [...impls].reverse() : impls;
|
|
189
|
+
const selected = ordered.find((impl) => impl != null && impl.origin === traitDef);
|
|
190
|
+
if (selected == null) {
|
|
191
|
+
const available = impls
|
|
192
|
+
.filter((impl) => impl?.origin != null)
|
|
193
|
+
.map((impl) => impl.origin.name.toString())
|
|
194
|
+
.join(" ");
|
|
195
|
+
throw new Error(`assert-traits failed: ${toString(value, true)} does not nominally implement ${traitDef.toString()}. Available trait impls: ${available || "(none)"}`);
|
|
196
|
+
}
|
|
197
|
+
const missing = traitDef.methods.filter((method) => selected.getOrNil(method) == null);
|
|
209
198
|
if (missing.length > 0) {
|
|
210
|
-
|
|
211
|
-
for (let j = 0; j < impls.length; j++) {
|
|
212
|
-
const impl = impls[j];
|
|
213
|
-
if (impl == null)
|
|
214
|
-
continue;
|
|
215
|
-
for (let k = 0; k < impl.fields.length; k++) {
|
|
216
|
-
available.push(impl.fields[k].toString());
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
throw new Error(`assert-traits failed: ${toString(value, true)} does not implement ${traitDef.toString()}. Missing: ${missing.join(" ")}. Available: ${available.join(" ")}`);
|
|
199
|
+
throw new Error(`assert-traits failed: impl ${selected.name.toString()} for trait ${traitDef.name.toString()} is incomplete. Missing: ${missing.join(" ")}`);
|
|
220
200
|
}
|
|
221
201
|
return value;
|
|
222
202
|
};
|
|
@@ -272,12 +252,14 @@ export let _$n_impl_$o__$o_new = (name, ...pairs) => {
|
|
|
272
252
|
throw new Error("&impl::new expected arguments");
|
|
273
253
|
const origin = name instanceof CalcitTrait ? name : null;
|
|
274
254
|
const implName = origin ? origin.name : castTag(name);
|
|
275
|
-
if (pairs.length === 0) {
|
|
276
|
-
return new CalcitImpl(implName, [], [], origin);
|
|
277
|
-
}
|
|
278
255
|
const entries = [];
|
|
279
|
-
|
|
280
|
-
|
|
256
|
+
let sourcePairs = pairs;
|
|
257
|
+
if (pairs.length === 1 && pairs[0] instanceof CalcitImpl) {
|
|
258
|
+
const sourceImpl = pairs[0];
|
|
259
|
+
sourcePairs = sourceImpl.fields.map((field, idx) => new CalcitTuple(field, [sourceImpl.values[idx]], null));
|
|
260
|
+
}
|
|
261
|
+
for (let idx = 0; idx < sourcePairs.length; idx++) {
|
|
262
|
+
const pairValue = sourcePairs[idx];
|
|
281
263
|
let fieldTag;
|
|
282
264
|
let value;
|
|
283
265
|
if (pairValue instanceof CalcitTuple) {
|
|
@@ -305,6 +287,23 @@ export let _$n_impl_$o__$o_new = (name, ...pairs) => {
|
|
|
305
287
|
}
|
|
306
288
|
const fields = entries.map((entry) => entry.tag);
|
|
307
289
|
const values = entries.map((entry) => entry.value);
|
|
290
|
+
if (origin != null) {
|
|
291
|
+
const missing = origin.methods.filter((method) => !fields.some((field) => field.value === method.value));
|
|
292
|
+
const unexpected = fields.filter((field) => !origin.methods.some((method) => method.value === field.value));
|
|
293
|
+
if (missing.length > 0 || unexpected.length > 0) {
|
|
294
|
+
const details = [];
|
|
295
|
+
if (missing.length > 0)
|
|
296
|
+
details.push(`missing methods: ${missing.join(" ")}`);
|
|
297
|
+
if (unexpected.length > 0)
|
|
298
|
+
details.push(`methods not declared by the trait: ${unexpected.join(" ")}`);
|
|
299
|
+
throw new Error(`&impl::new does not conform to trait ${origin.name.toString()}: ${details.join("; ")}`);
|
|
300
|
+
}
|
|
301
|
+
for (const entry of entries) {
|
|
302
|
+
if (typeof entry.value !== "function") {
|
|
303
|
+
throw new Error(`&impl::new expects trait method .${entry.tag.value} to be a function, but received: ${toString(entry.value, true)}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
308
307
|
return new CalcitImpl(implName, fields, values, origin);
|
|
309
308
|
};
|
|
310
309
|
export let _$n_struct_$o__$o_new = (name, ...entries) => {
|
|
@@ -1764,6 +1763,7 @@ let calcit_builtin_impls = {
|
|
|
1764
1763
|
fn: null,
|
|
1765
1764
|
tuple: null,
|
|
1766
1765
|
record: null,
|
|
1766
|
+
scalar: null,
|
|
1767
1767
|
};
|
|
1768
1768
|
// need to register code from outside
|
|
1769
1769
|
export let register_calcit_builtin_impls = (options) => {
|
|
@@ -1839,11 +1839,13 @@ function lookup_impls(obj) {
|
|
|
1839
1839
|
// impls, so introspection tools like `&methods-of` can answer "what
|
|
1840
1840
|
// methods will instances of this type have" without a concrete instance.
|
|
1841
1841
|
tag = obj.name.toString();
|
|
1842
|
-
|
|
1842
|
+
const builtinRecordImpls = normalize_builtin_impls(calcit_builtin_impls.record) ?? [];
|
|
1843
|
+
impls = [...builtinRecordImpls, ...(obj.impls ?? [])];
|
|
1843
1844
|
}
|
|
1844
1845
|
else if (obj instanceof CalcitEnum) {
|
|
1845
1846
|
tag = obj.name();
|
|
1846
|
-
|
|
1847
|
+
const builtinTupleImpls = normalize_builtin_impls(calcit_builtin_impls.tuple) ?? [];
|
|
1848
|
+
impls = [...builtinTupleImpls, ...(obj.impls ?? [])];
|
|
1847
1849
|
}
|
|
1848
1850
|
else if (typeof obj === "number") {
|
|
1849
1851
|
tag = "&core-number-methods";
|
|
@@ -1857,6 +1859,14 @@ function lookup_impls(obj) {
|
|
|
1857
1859
|
tag = "&core-fn-methods";
|
|
1858
1860
|
impls = normalize_builtin_impls(calcit_builtin_impls.fn);
|
|
1859
1861
|
}
|
|
1862
|
+
else if (obj == null ||
|
|
1863
|
+
typeof obj === "boolean" ||
|
|
1864
|
+
obj instanceof CalcitTag ||
|
|
1865
|
+
obj instanceof CalcitSymbol ||
|
|
1866
|
+
obj instanceof CalcitCirruQuote) {
|
|
1867
|
+
tag = "&core-scalar-impls";
|
|
1868
|
+
impls = normalize_builtin_impls(calcit_builtin_impls.scalar);
|
|
1869
|
+
}
|
|
1860
1870
|
else {
|
|
1861
1871
|
return null;
|
|
1862
1872
|
}
|
|
@@ -1997,7 +2007,7 @@ export function _$n_trait_call(traitDef, method, obj, ...args) {
|
|
|
1997
2007
|
let idx = reverse ? impls.length - 1 : 0;
|
|
1998
2008
|
while (reverse ? idx >= 0 : idx < impls.length) {
|
|
1999
2009
|
const impl = impls[idx];
|
|
2000
|
-
if (impl != null && impl.origin
|
|
2010
|
+
if (impl != null && impl.origin === traitDef) {
|
|
2001
2011
|
const fn = impl.getOrNil(methodName);
|
|
2002
2012
|
if (fn != null) {
|
|
2003
2013
|
if (typeof fn !== "function") {
|
package/lib/package.json
CHANGED