aontu 0.62.0 → 0.64.0
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/README.md +7 -7
- package/dist/agentsmd.js +0 -27
- package/dist/agentsmd.js.map +1 -1
- package/dist/alias.js.map +1 -1
- package/dist/allow.js +0 -92
- package/dist/allow.js.map +1 -1
- package/dist/aontu.d.ts +3 -3
- package/dist/aontu.js +4 -84
- package/dist/aontu.js.map +1 -1
- package/dist/aontumodel.d.ts +4 -0
- package/dist/aontumodel.js +27 -0
- package/dist/aontumodel.js.map +1 -0
- package/dist/casing.d.ts +5 -0
- package/dist/casing.js +90 -0
- package/dist/casing.js.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +228 -935
- package/dist/cli.js.map +1 -1
- package/dist/ctx.js +0 -48
- package/dist/ctx.js.map +1 -1
- package/dist/diff.js +0 -32
- package/dist/diff.js.map +1 -1
- package/dist/err.js +0 -40
- package/dist/err.js.map +1 -1
- package/dist/escape.js +0 -45
- package/dist/escape.js.map +1 -1
- package/dist/exactjson.d.ts +0 -35
- package/dist/exactjson.js +0 -131
- package/dist/exactjson.js.map +1 -1
- package/dist/format.js +13 -203
- package/dist/format.js.map +1 -1
- package/dist/grammar.d.ts +9 -0
- package/dist/grammar.js +54 -0
- package/dist/grammar.js.map +1 -0
- package/dist/graph.js +0 -26
- package/dist/graph.js.map +1 -1
- package/dist/hcanon.js +0 -82
- package/dist/hcanon.js.map +1 -1
- package/dist/helpdoc.js +2 -2
- package/dist/helpdoc.js.map +1 -1
- package/dist/hints.d.ts +0 -6
- package/dist/hints.js +57 -55
- package/dist/hints.js.map +1 -1
- package/dist/jsonschema.js +0 -114
- package/dist/jsonschema.js.map +1 -1
- package/dist/keyorder.d.ts +0 -7
- package/dist/keyorder.js +0 -41
- package/dist/keyorder.js.map +1 -1
- package/dist/lang.js +17 -915
- package/dist/lang.js.map +1 -1
- package/dist/lsp-server.js +0 -16
- package/dist/lsp-server.js.map +1 -1
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +12 -159
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.js +0 -26
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp.js +0 -149
- package/dist/mcp.js.map +1 -1
- package/dist/mod-tool.js +16 -131
- package/dist/mod-tool.js.map +1 -1
- package/dist/mod.js +0 -162
- package/dist/mod.js.map +1 -1
- package/dist/patch.js +0 -217
- package/dist/patch.js.map +1 -1
- package/dist/profile.d.ts +9 -0
- package/dist/profile.js +28 -0
- package/dist/profile.js.map +1 -0
- package/dist/provenance.js +0 -140
- package/dist/provenance.js.map +1 -1
- package/dist/query.js +0 -75
- package/dist/query.js.map +1 -1
- package/dist/reach.js +0 -43
- package/dist/reach.js.map +1 -1
- package/dist/relation.js +0 -61
- package/dist/relation.js.map +1 -1
- package/dist/report-sarif.d.ts +0 -11
- package/dist/report-sarif.js +0 -28
- package/dist/report-sarif.js.map +1 -1
- package/dist/sig.js +0 -35
- package/dist/sig.js.map +1 -1
- package/dist/sigdecl.js +1 -1
- package/dist/sigdecl.js.map +1 -1
- package/dist/siggate.js +0 -4
- package/dist/siggate.js.map +1 -1
- package/dist/site.js +3 -29
- package/dist/site.js.map +1 -1
- package/dist/subsume.d.ts +0 -10
- package/dist/subsume.js +0 -137
- package/dist/subsume.js.map +1 -1
- package/dist/template.d.ts +2 -1
- package/dist/template.js +58 -138
- package/dist/template.js.map +1 -1
- package/dist/trace.d.ts +21 -0
- package/dist/trace.js +107 -0
- package/dist/trace.js.map +1 -0
- package/dist/trim.js +0 -41
- package/dist/trim.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.js.map +1 -1
- package/dist/unify.js +13 -248
- package/dist/unify.js.map +1 -1
- package/dist/utility.js +0 -22
- package/dist/utility.js.map +1 -1
- package/dist/val/AbnfFuncVal.d.ts +18 -0
- package/dist/val/AbnfFuncVal.js +132 -0
- package/dist/val/AbnfFuncVal.js.map +1 -0
- package/dist/val/AbsentVal.d.ts +11 -0
- package/dist/val/AbsentVal.js +30 -0
- package/dist/val/AbsentVal.js.map +1 -0
- package/dist/val/AggFuncVal.d.ts +10 -1
- package/dist/val/AggFuncVal.js +104 -116
- package/dist/val/AggFuncVal.js.map +1 -1
- package/dist/val/ArithFuncVal.js +0 -12
- package/dist/val/ArithFuncVal.js.map +1 -1
- package/dist/val/BagVal.js +1 -78
- package/dist/val/BagVal.js.map +1 -1
- package/dist/val/BigDecimalVal.js +0 -16
- package/dist/val/BigDecimalVal.js.map +1 -1
- package/dist/val/BigIntegerVal.js +0 -16
- package/dist/val/BigIntegerVal.js.map +1 -1
- package/dist/val/CloseFuncVal.js +0 -9
- package/dist/val/CloseFuncVal.js.map +1 -1
- package/dist/val/CmpFuncVal.d.ts +2 -0
- package/dist/val/CmpFuncVal.js +49 -72
- package/dist/val/CmpFuncVal.js.map +1 -1
- package/dist/val/ConjunctVal.js +0 -29
- package/dist/val/ConjunctVal.js.map +1 -1
- package/dist/val/ConstraintVal.js +0 -500
- package/dist/val/ConstraintVal.js.map +1 -1
- package/dist/val/ContainerKindVal.js +0 -2
- package/dist/val/ContainerKindVal.js.map +1 -1
- package/dist/val/CopyFuncVal.js +0 -3
- package/dist/val/CopyFuncVal.js.map +1 -1
- package/dist/val/Decimal.js +0 -179
- package/dist/val/Decimal.js.map +1 -1
- package/dist/val/DeprecateFuncVal.js.map +1 -1
- package/dist/val/DisjunctVal.js +0 -152
- package/dist/val/DisjunctVal.js.map +1 -1
- package/dist/val/EachFuncVal.js +0 -3
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/EmitFuncVal.d.ts +1 -1
- package/dist/val/EmitFuncVal.js +6 -119
- package/dist/val/EmitFuncVal.js.map +1 -1
- package/dist/val/ExpectVal.js +0 -62
- package/dist/val/ExpectVal.js.map +1 -1
- package/dist/val/FilterFuncVal.js +0 -25
- package/dist/val/FilterFuncVal.js.map +1 -1
- package/dist/val/FuncBaseVal.d.ts +1 -0
- package/dist/val/FuncBaseVal.js +7 -127
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/GraphAtomVal.js +0 -15
- package/dist/val/GraphAtomVal.js.map +1 -1
- package/dist/val/HideFuncVal.js +0 -13
- package/dist/val/HideFuncVal.js.map +1 -1
- package/dist/val/IntegerVal.js +0 -61
- package/dist/val/IntegerVal.js.map +1 -1
- package/dist/val/JunctionVal.js +0 -20
- package/dist/val/JunctionVal.js.map +1 -1
- package/dist/val/KeyFuncVal.js +0 -46
- package/dist/val/KeyFuncVal.js.map +1 -1
- package/dist/val/ListVal.js +0 -57
- package/dist/val/ListVal.js.map +1 -1
- package/dist/val/LowerFuncVal.js +0 -11
- package/dist/val/LowerFuncVal.js.map +1 -1
- package/dist/val/MapVal.js +0 -151
- package/dist/val/MapVal.js.map +1 -1
- package/dist/val/MatchFuncVal.js +0 -27
- package/dist/val/MatchFuncVal.js.map +1 -1
- package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
- package/dist/val/MaybeFuncVal.js +50 -0
- package/dist/val/MaybeFuncVal.js.map +1 -0
- package/dist/val/MoveFuncVal.js +0 -18
- package/dist/val/MoveFuncVal.js.map +1 -1
- package/dist/val/NilVal.js +0 -60
- package/dist/val/NilVal.js.map +1 -1
- package/dist/val/NomFuncVal.js +18 -54
- package/dist/val/NomFuncVal.js.map +1 -1
- package/dist/val/NumberVal.js +0 -15
- package/dist/val/NumberVal.js.map +1 -1
- package/dist/val/OpBaseVal.d.ts +1 -0
- package/dist/val/OpBaseVal.js +3 -15
- package/dist/val/OpBaseVal.js.map +1 -1
- package/dist/val/PackFuncVal.js +0 -34
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/PathFuncVal.js +0 -6
- package/dist/val/PathFuncVal.js.map +1 -1
- package/dist/val/PathVal.js +0 -41
- package/dist/val/PathVal.js.map +1 -1
- package/dist/val/PlaceVal.js +0 -25
- package/dist/val/PlaceVal.js.map +1 -1
- package/dist/val/PlusOpVal.d.ts +1 -7
- package/dist/val/PlusOpVal.js +13 -74
- package/dist/val/PlusOpVal.js.map +1 -1
- package/dist/val/PrefFuncVal.js +0 -1
- package/dist/val/PrefFuncVal.js.map +1 -1
- package/dist/val/PrefVal.js +0 -167
- package/dist/val/PrefVal.js.map +1 -1
- package/dist/val/RecurseVal.js +0 -55
- package/dist/val/RecurseVal.js.map +1 -1
- package/dist/val/RefVal.js +0 -282
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/ReferFuncVal.js +3 -232
- package/dist/val/ReferFuncVal.js.map +1 -1
- package/dist/val/ScalarKindVal.js +0 -49
- package/dist/val/ScalarKindVal.js.map +1 -1
- package/dist/val/ScalarVal.js +0 -11
- package/dist/val/ScalarVal.js.map +1 -1
- package/dist/val/StrFuncVal.js +0 -18
- package/dist/val/StrFuncVal.js.map +1 -1
- package/dist/val/SuperFuncVal.js +0 -32
- package/dist/val/SuperFuncVal.js.map +1 -1
- package/dist/val/TopVal.js +0 -1
- package/dist/val/TopVal.js.map +1 -1
- package/dist/val/TranslateFuncVal.js +1 -3
- package/dist/val/TranslateFuncVal.js.map +1 -1
- package/dist/val/UpperFuncVal.js +0 -11
- package/dist/val/UpperFuncVal.js.map +1 -1
- package/dist/val/Val.d.ts +1 -0
- package/dist/val/Val.js +2 -133
- package/dist/val/Val.js.map +1 -1
- package/dist/val/VarVal.js +0 -12
- package/dist/val/VarVal.js.map +1 -1
- package/dist/val/arith.js +0 -37
- package/dist/val/arith.js.map +1 -1
- package/dist/val/caserange.js +0 -61
- package/dist/val/caserange.js.map +1 -1
- package/dist/val/members.js +0 -6
- package/dist/val/members.js.map +1 -1
- package/dist/val/numcmp.js +0 -11
- package/dist/val/numcmp.js.map +1 -1
- package/dist/val/numkind.js +0 -145
- package/dist/val/numkind.js.map +1 -1
- package/dist/val/valutil.js +0 -16
- package/dist/val/valutil.js.map +1 -1
- package/dist/vet.js +0 -461
- package/dist/vet.js.map +1 -1
- package/dist/view.js +0 -414
- package/dist/view.js.map +1 -1
- package/dist/walk.js +0 -41
- package/dist/walk.js.map +1 -1
- package/grammar/aontu.abnf +8 -6
- package/grammar/aontu.gbnf +4 -4
- package/grammar/aontu.lark +4 -4
- package/grammar/aontu.tmLanguage.json +1 -1
- package/package.json +4 -2
- package/skill/tasks.md +9 -7
- package/src/agentsmd.ts +0 -35
- package/src/alias.ts +0 -39
- package/src/allow.ts +1 -96
- package/src/aontu.ts +4 -116
- package/src/aontumodel.ts +26 -0
- package/src/casing.ts +95 -0
- package/src/cli.ts +258 -1024
- package/src/ctx.ts +0 -103
- package/src/diff.ts +0 -40
- package/src/err.ts +0 -40
- package/src/escape.ts +0 -46
- package/src/exactjson.ts +0 -131
- package/src/format.ts +14 -257
- package/src/grammar.ts +72 -0
- package/src/graph.ts +0 -61
- package/src/hcanon.ts +0 -82
- package/src/helpdoc.ts +2 -2
- package/src/hints.ts +69 -57
- package/src/jsonschema.ts +0 -123
- package/src/keyorder.ts +0 -42
- package/src/lang.ts +19 -931
- package/src/lsp-server.ts +0 -16
- package/src/lsp.ts +12 -180
- package/src/mcp-server.ts +0 -31
- package/src/mcp.ts +0 -169
- package/src/mod-tool.ts +18 -159
- package/src/mod.ts +0 -178
- package/src/patch.ts +0 -232
- package/src/profile.ts +42 -0
- package/src/provenance.ts +0 -183
- package/src/query.ts +0 -84
- package/src/reach.ts +0 -53
- package/src/relation.ts +0 -84
- package/src/report-sarif.ts +0 -48
- package/src/sig.ts +0 -35
- package/src/sigdecl.ts +1 -1
- package/src/siggate.ts +0 -30
- package/src/site.ts +3 -29
- package/src/subsume.ts +1 -161
- package/src/template.ts +69 -140
- package/src/trace.ts +157 -0
- package/src/trim.ts +0 -53
- package/src/type.ts +2 -45
- package/src/unify.ts +14 -257
- package/src/utility.ts +0 -31
- package/src/val/AbnfFuncVal.ts +181 -0
- package/src/val/AbsentVal.ts +54 -0
- package/src/val/AggFuncVal.ts +152 -188
- package/src/val/ArithFuncVal.ts +0 -20
- package/src/val/BagVal.ts +1 -78
- package/src/val/BigDecimalVal.ts +0 -16
- package/src/val/BigIntegerVal.ts +0 -16
- package/src/val/CloseFuncVal.ts +0 -9
- package/src/val/CmpFuncVal.ts +68 -184
- package/src/val/ConjunctVal.ts +0 -33
- package/src/val/ConstraintVal.ts +2 -537
- package/src/val/ContainerKindVal.ts +0 -18
- package/src/val/CopyFuncVal.ts +0 -5
- package/src/val/Decimal.ts +1 -185
- package/src/val/DeprecateFuncVal.ts +0 -10
- package/src/val/DisjunctVal.ts +0 -157
- package/src/val/EachFuncVal.ts +0 -40
- package/src/val/EmitFuncVal.ts +8 -208
- package/src/val/ExpectVal.ts +0 -62
- package/src/val/FilterFuncVal.ts +0 -55
- package/src/val/FuncBaseVal.ts +9 -130
- package/src/val/GraphAtomVal.ts +0 -42
- package/src/val/HideFuncVal.ts +0 -15
- package/src/val/IntegerVal.ts +0 -61
- package/src/val/JunctionVal.ts +0 -20
- package/src/val/KeyFuncVal.ts +0 -48
- package/src/val/ListVal.ts +0 -59
- package/src/val/LowerFuncVal.ts +0 -12
- package/src/val/MapVal.ts +0 -151
- package/src/val/MatchFuncVal.ts +0 -59
- package/src/val/MaybeFuncVal.ts +86 -0
- package/src/val/MoveFuncVal.ts +0 -20
- package/src/val/NilVal.ts +0 -60
- package/src/val/NomFuncVal.ts +10 -99
- package/src/val/NumberVal.ts +0 -16
- package/src/val/OpBaseVal.ts +4 -17
- package/src/val/PackFuncVal.ts +0 -63
- package/src/val/PathFuncVal.ts +0 -32
- package/src/val/PathVal.ts +0 -66
- package/src/val/PlaceVal.ts +0 -45
- package/src/val/PlusOpVal.ts +18 -75
- package/src/val/PrefFuncVal.ts +0 -1
- package/src/val/PrefVal.ts +0 -179
- package/src/val/RecurseVal.ts +0 -81
- package/src/val/RefVal.ts +1 -285
- package/src/val/ReferFuncVal.ts +4 -255
- package/src/val/ScalarKindVal.ts +0 -50
- package/src/val/ScalarVal.ts +0 -12
- package/src/val/StrFuncVal.ts +0 -44
- package/src/val/SuperFuncVal.ts +0 -42
- package/src/val/TopVal.ts +0 -1
- package/src/val/TranslateFuncVal.ts +1 -51
- package/src/val/UpperFuncVal.ts +0 -12
- package/src/val/Val.ts +3 -192
- package/src/val/VarVal.ts +0 -15
- package/src/val/arith.ts +0 -92
- package/src/val/caserange.ts +0 -62
- package/src/val/members.ts +0 -23
- package/src/val/numcmp.ts +1 -27
- package/src/val/numkind.ts +0 -149
- package/src/val/valutil.ts +0 -16
- package/src/vet.ts +1 -582
- package/src/view.ts +0 -507
- package/src/walk.ts +0 -41
- package/dist/lower.d.ts +0 -23
- package/dist/lower.js +0 -578
- package/dist/lower.js.map +0 -1
- package/dist/render.d.ts +0 -53
- package/dist/render.js +0 -547
- package/dist/render.js.map +0 -1
- package/dist/std.d.ts +0 -3
- package/dist/std.js +0 -672
- package/dist/std.js.map +0 -1
- package/dist/val/FormFuncVal.js +0 -55
- package/dist/val/FormFuncVal.js.map +0 -1
- package/dist/val/NamerFuncVal.d.ts +0 -12
- package/dist/val/NamerFuncVal.js +0 -176
- package/dist/val/NamerFuncVal.js.map +0 -1
- package/src/lower.ts +0 -636
- package/src/render.ts +0 -732
- package/src/std.ts +0 -683
package/src/val/FuncBaseVal.ts
CHANGED
|
@@ -33,16 +33,6 @@ import { FeatureVal } from '../val/FeatureVal'
|
|
|
33
33
|
import { hasPlace, fillPlace } from '../val/PlaceVal'
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
// A TRIAL meet: does `a` unify with `b`, and if so as what? Failure is
|
|
37
|
-
// an ANSWER here rather than an error, which is exactly what
|
|
38
|
-
// DisjunctVal already needs when it tries each member against a peer —
|
|
39
|
-
// so this is that mechanism (`ctx._trialMode`, which makes makeNilErr
|
|
40
|
-
// return the shared TRIAL_NIL instead of allocating and recording),
|
|
41
|
-
// lent to the combinators that select by unifiability.
|
|
42
|
-
//
|
|
43
|
-
// The error list and the trial flag are saved and restored in a
|
|
44
|
-
// `finally`: a trial that throws must not leave the surrounding
|
|
45
|
-
// evaluation collapsing every later error into the sentinel.
|
|
46
36
|
function trialUnify(ctx: AontuContext, a: Val, b: Val): Val | undefined {
|
|
47
37
|
const savedErr = ctx.err
|
|
48
38
|
const savedTrial = ctx._trialMode
|
|
@@ -83,15 +73,10 @@ function trialUnify(ctx: AontuContext, a: Val, b: Val): Val | undefined {
|
|
|
83
73
|
|
|
84
74
|
class FuncBaseVal extends FeatureVal {
|
|
85
75
|
isFunc = true
|
|
76
|
+
|
|
77
|
+
forgives = false
|
|
86
78
|
isGenable = true
|
|
87
79
|
|
|
88
|
-
// THE STAGING RULE (G8 phase 0, see AontuContext.settle). A func
|
|
89
|
-
// whose answer depends on WHERE IT IS -- `key()`, whose answer is a
|
|
90
|
-
// segment of its own path, and the generation combinators, whose
|
|
91
|
-
// data argument can still be merged into by a sibling -- sets this
|
|
92
|
-
// and residuates until the model stops moving. Everything else
|
|
93
|
-
// resolves as soon as its arguments are done, which is the rule that
|
|
94
|
-
// has always been here.
|
|
95
80
|
staged = false
|
|
96
81
|
|
|
97
82
|
constructor(
|
|
@@ -99,13 +84,11 @@ class FuncBaseVal extends FeatureVal {
|
|
|
99
84
|
ctx?: AontuContext
|
|
100
85
|
) {
|
|
101
86
|
super(spec, ctx)
|
|
102
|
-
// console.log('FBV', this.id, this.constructor.name, this.peg?.[0]?.canon)
|
|
103
87
|
}
|
|
104
88
|
|
|
105
89
|
|
|
106
90
|
validateArgs(args: Val[], min: number) {
|
|
107
91
|
if (min < args.length) {
|
|
108
|
-
// TODO: this is an error as as a parse error, needs to be handled same way
|
|
109
92
|
throw new AontuError('The ' + this.funcname() + ' function needs at least ' +
|
|
110
93
|
min + ' argument' + (1 === min ? '' : 's') + '.')
|
|
111
94
|
}
|
|
@@ -117,28 +100,10 @@ class FuncBaseVal extends FeatureVal {
|
|
|
117
100
|
}
|
|
118
101
|
|
|
119
102
|
|
|
120
|
-
// Drive the first `count` arguments IN PLACE, every pass — not only
|
|
121
|
-
// on the settle pass. A staged func waits for the model to settle,
|
|
122
|
-
// and its own arguments are part of that model: leaving them
|
|
123
|
-
// standing until settle would guarantee the model was still moving
|
|
124
|
-
// when settle arrived. Answers whether they are all done, which is
|
|
125
|
-
// the other half of "ready to fire".
|
|
126
103
|
driveStagedArgs(ctx: AontuContext, count: number): boolean {
|
|
127
104
|
const TOP = top()
|
|
128
105
|
let alldone = true
|
|
129
106
|
|
|
130
|
-
// THE SNAPSHOT WAITS FOR THE SOURCE (the spread-then-pack defect,
|
|
131
|
-
// use-cases/BUGS.md pack-refs family). A reference resolving inside
|
|
132
|
-
// a staged argument is this argument's SNAPSHOT of its source, and
|
|
133
|
-
// the snapshot is not part of the tree: a spread-injected relative
|
|
134
|
-
// reference inside a too-early copy dangles at the argument's
|
|
135
|
-
// location (`.containerPort` rebased under the generator, where no
|
|
136
|
-
// root traversal reaches it) and the generator never fires. The
|
|
137
|
-
// `argsnap` flag makes RefVal.find defer until the target has
|
|
138
|
-
// finished resolving IN THE TREE — where its own spreads and
|
|
139
|
-
// relative references answer at their real location — and only then
|
|
140
|
-
// take the copy. Inherited by every descended ctx, so a reference
|
|
141
|
-
// anywhere in the argument subtree waits the same way.
|
|
142
107
|
const actx: AontuContext = ctx.clone({})
|
|
143
108
|
; (actx as any).argsnap = true
|
|
144
109
|
|
|
@@ -156,47 +121,15 @@ class FuncBaseVal extends FeatureVal {
|
|
|
156
121
|
}
|
|
157
122
|
|
|
158
123
|
|
|
159
|
-
// THE STAGED READINESS GATE, stated once for the generators that
|
|
160
|
-
// drive their own data argument. Such a func fires when the model
|
|
161
|
-
// has settled AND that argument is done -- EXCEPT when the argument
|
|
162
|
-
// is a HOLE and a PEER has arrived to fill it. `_` is never done: it
|
|
163
|
-
// is FILLED, and the peer is what fills it, so gating on doneness
|
|
164
|
-
// alone held every placeheld generator residual for ever and the
|
|
165
|
-
// fill in `unify` below was never reached (`["a"] & pack(_, {x:1})`
|
|
166
|
-
// was `*_no_gen`, while the unstaged `"hello" & upper(_)` filled as
|
|
167
|
-
// documented -- an undriven `_` makes an ordinary call's `pegdone`
|
|
168
|
-
// false, and a generator's prepare() forces it true). Against TOP
|
|
169
|
-
// there is nothing to fill with, so a placeheld generator waits
|
|
170
|
-
// exactly as the hole itself does.
|
|
171
124
|
stagedReady(peer: Val, ctx: AontuContext, count: number): boolean {
|
|
172
125
|
const ready = this.driveStagedArgs(ctx, count)
|
|
173
126
|
return (ready || (!peer.isTop && hasPlace(this))) && true === ctx.settle
|
|
174
127
|
}
|
|
175
128
|
|
|
176
129
|
|
|
177
|
-
// THE PER-DESTINATION INSTANTIATION RULE (ADR-005). The default
|
|
178
|
-
// clone shares the argument array AND the argument Vals — the
|
|
179
|
-
// residuation clone, which stays at one position and wants the
|
|
180
|
-
// sharing, and the reference copy of a target that still holds a
|
|
181
|
-
// staged call, which pins the move()/copy() ghost artifacts
|
|
182
|
-
// (test/spec/func.tsv, ghost-*-innard-canon; ADR-025) — but a clone
|
|
183
|
-
// that is an INSTANCE must own the full inner structure: with the
|
|
184
|
-
// args shared, `pack($.names, close({name: key()}))` resolved key()
|
|
185
|
-
// once inside the one shared inner map and stamped the FIRST
|
|
186
|
-
// child's key on every child (use-cases/BUGS.md §8). The `dup` spec
|
|
187
|
-
// flag asks for that depth; everything else keeps the sharing it
|
|
188
|
-
// has always had.
|
|
189
130
|
clone(ctx: AontuContext, spec?: ValSpec): Val {
|
|
190
131
|
const out = super.clone(ctx, spec) as FuncBaseVal
|
|
191
132
|
if (true === spec?.dup && Array.isArray(this.peg)) {
|
|
192
|
-
// Every argument is a Val by construction (the parser builds
|
|
193
|
-
// them; make() rebuilds from driven Vals), as the Go twin's
|
|
194
|
-
// []Val typing states outright. The generator and spread
|
|
195
|
-
// instantiation sites then normalise every path in the clone
|
|
196
|
-
// (repathInstance), so the argument-shaped parse paths never
|
|
197
|
-
// leak into an instance; the reference copy takes the paths
|
|
198
|
-
// this rebasing gives, which is what an absolute address in a
|
|
199
|
-
// copied model already expects (ADR-014).
|
|
200
133
|
out.peg = this.peg.map((a: Val) => a.clone(ctx, { dup: true }))
|
|
201
134
|
}
|
|
202
135
|
return out
|
|
@@ -237,16 +170,7 @@ class FuncBaseVal extends FeatureVal {
|
|
|
237
170
|
return this.residuate(peer, ctx)
|
|
238
171
|
}
|
|
239
172
|
|
|
240
|
-
// THE PLACEHOLDER (G8 phase 3, see PlaceVal). A call holding a hole
|
|
241
|
-
// waits for a peer, and the peer is what fills it: the call is
|
|
242
|
-
// rebuilt with the hole replaced and resolved on the spot, so
|
|
243
|
-
// `upper(_) & hello` is `"HELLO"` and not `"HELLO" & "hello"` --
|
|
244
|
-
// the peer went INTO the call, it is not also a constraint on the
|
|
245
|
-
// way out.
|
|
246
173
|
if (!peer.isTop && !peer.isNil && this.id !== peer.id && hasPlace(this)) {
|
|
247
|
-
// TWO HOLES AND NOTHING TO FILL THEM. `upper(_) & lower(_)` has
|
|
248
|
-
// no value on either side, and picking one call to be the other's
|
|
249
|
-
// filling would be inventing an order the language does not have.
|
|
250
174
|
if (hasPlace(peer)) {
|
|
251
175
|
return makeNilErr(ctx, 'place_pair', this, peer)
|
|
252
176
|
}
|
|
@@ -256,16 +180,11 @@ class FuncBaseVal extends FeatureVal {
|
|
|
256
180
|
const TOP = top()
|
|
257
181
|
const te = ctx.explain && explainOpen(ctx, ctx.explain, 'Func:' + this.funcname(), this, peer)
|
|
258
182
|
|
|
259
|
-
// const sc = this.id + '=' + this.canon
|
|
260
|
-
// const pc = peer.id + '=' + peer.canon
|
|
261
|
-
|
|
262
183
|
|
|
263
184
|
let why = ''
|
|
264
185
|
let out: Val = this
|
|
265
186
|
|
|
266
187
|
|
|
267
|
-
// console.log('FBV', this.id, this.constructor.name, this.mark.type, this.peg?.canon, 'PEER', peer.id, peer.canon)
|
|
268
|
-
|
|
269
188
|
let pegdone = true
|
|
270
189
|
|
|
271
190
|
if (this.id !== peer.id) {
|
|
@@ -290,20 +209,13 @@ class FuncBaseVal extends FeatureVal {
|
|
|
290
209
|
this.peg = pegprep
|
|
291
210
|
|
|
292
211
|
for (let arg of this.peg) {
|
|
293
|
-
// console.log('FUNCBASE-UNIFY-PEG-A', arg.canon)
|
|
294
212
|
|
|
295
213
|
let newarg = arg
|
|
296
214
|
if (!arg.done) {
|
|
297
|
-
// Charged to the depth budget: this recurses without going
|
|
298
|
-
// through `unite`, so the counter would otherwise stay flat
|
|
299
|
-
// while the stack grows (see withDepth in unify.ts). The
|
|
300
|
-
// arg context is built OUTSIDE the closure so its explain
|
|
301
|
-
// ternary stays one branch rather than one per call.
|
|
302
215
|
const argctx = te ? ctx.clone({ explain: ec(te, 'ARG') }) : ctx
|
|
303
216
|
newarg = withDepth(ctx, arg, TOP, () => arg.unify(TOP, argctx))
|
|
304
217
|
newtype = newtype || newarg.mark.type
|
|
305
218
|
newhide = newhide || newarg.mark.hide
|
|
306
|
-
// console.log('FUNCBASE-UNIFY-PEG-B', arg.canon, arg.done, '->', newarg.canon, newarg.done)
|
|
307
219
|
}
|
|
308
220
|
// pegdone &&= arg.done
|
|
309
221
|
pegdone &&= newarg.done
|
|
@@ -313,14 +225,18 @@ class FuncBaseVal extends FeatureVal {
|
|
|
313
225
|
|
|
314
226
|
// console.log('FUNCBASE-PEG', this.id, pegdone, this.peg.map((p: any) => p?.canon))
|
|
315
227
|
|
|
316
|
-
|
|
228
|
+
// ABSENCE PROPAGATES (ADR-034), ahead of deferResolve.
|
|
229
|
+
const gone = this.forgives ? undefined :
|
|
230
|
+
newpeg.find((a: Val) => true === (a as any).isAbsent)
|
|
231
|
+
|
|
232
|
+
if (pegdone &&
|
|
233
|
+
(undefined !== gone || !this.deferResolve(ctx, newpeg))) {
|
|
317
234
|
// THE SIGNATURE GATE (docs/design/SIGNATURES.0.md): the
|
|
318
235
|
// driven arguments against the declared signature, before
|
|
319
236
|
// the builtin's own logic sees them. See siggate.ts for
|
|
320
237
|
// what the gate owns and what stays with the builtins.
|
|
321
|
-
const resolved = sigRefuse(ctx, this, newpeg) ??
|
|
238
|
+
const resolved = gone ?? sigRefuse(ctx, this, newpeg) ??
|
|
322
239
|
this.resolve(ctx, newpeg)
|
|
323
|
-
// console.log('FUNC-RESOLVED', ctx.cc, resolved?.canon)
|
|
324
240
|
|
|
325
241
|
// The TOP peer is DROPPED as the unit it is.
|
|
326
242
|
out = resolved.done && peer.isTop ? resolved :
|
|
@@ -328,19 +244,9 @@ class FuncBaseVal extends FeatureVal {
|
|
|
328
244
|
resolved, peer, 'func-' + this.funcname() + '/' + this.id)
|
|
329
245
|
propagateMarks(this, out)
|
|
330
246
|
|
|
331
|
-
// TODO: make should handle this using ctx?
|
|
332
247
|
out.site.row = this.site.row
|
|
333
248
|
out.site.col = this.site.col
|
|
334
249
|
out.site.url = this.site.url
|
|
335
|
-
// THE SPAN COMES WITH THE POSITION, always. Moving row and
|
|
336
|
-
// col onto the result while leaving its own text behind
|
|
337
|
-
// produced a site that contradicted itself: `close({...})`
|
|
338
|
-
// reported the call's column and the map's `{`, so reading
|
|
339
|
-
// the document at (row, col, len) found `c` where `src` said
|
|
340
|
-
// `{`. A consumer following the verification contract would
|
|
341
|
-
// refuse every such repair; one skipping it would edit the
|
|
342
|
-
// wrong token. Whatever the position names, the text names
|
|
343
|
-
// too. Twin: the same assignment in go/func.go.
|
|
344
250
|
out.site.len = this.site.len
|
|
345
251
|
out.site.src = this.site.src
|
|
346
252
|
out.path = this.path
|
|
@@ -351,19 +257,9 @@ class FuncBaseVal extends FeatureVal {
|
|
|
351
257
|
this.notdone()
|
|
352
258
|
out = this.make(ctx, { peg: newpeg, mark: { type: newtype, hide: newhide } })
|
|
353
259
|
|
|
354
|
-
// TODO: make should handle this using ctx?
|
|
355
260
|
out.site.row = this.site.row
|
|
356
261
|
out.site.col = this.site.col
|
|
357
262
|
out.site.url = this.site.url
|
|
358
|
-
// THE SPAN COMES WITH THE POSITION, always. Moving row and
|
|
359
|
-
// col onto the result while leaving its own text behind
|
|
360
|
-
// produced a site that contradicted itself: `close({...})`
|
|
361
|
-
// reported the call's column and the map's `{`, so reading
|
|
362
|
-
// the document at (row, col, len) found `c` where `src` said
|
|
363
|
-
// `{`. A consumer following the verification contract would
|
|
364
|
-
// refuse every such repair; one skipping it would edit the
|
|
365
|
-
// wrong token. Whatever the position names, the text names
|
|
366
|
-
// too. Twin: the same assignment in go/func.go.
|
|
367
263
|
out.site.len = this.site.len
|
|
368
264
|
out.site.src = this.site.src
|
|
369
265
|
out.path = this.path
|
|
@@ -381,19 +277,9 @@ class FuncBaseVal extends FeatureVal {
|
|
|
381
277
|
peg: [this, peer], mark: { type: newtype, hide: newhide }
|
|
382
278
|
}, ctx)
|
|
383
279
|
|
|
384
|
-
// TODO: make should handle this using ctx?
|
|
385
280
|
out.site.row = this.site.row
|
|
386
281
|
out.site.col = this.site.col
|
|
387
282
|
out.site.url = this.site.url
|
|
388
|
-
// THE SPAN COMES WITH THE POSITION, always. Moving row and
|
|
389
|
-
// col onto the result while leaving its own text behind
|
|
390
|
-
// produced a site that contradicted itself: `close({...})`
|
|
391
|
-
// reported the call's column and the map's `{`, so reading
|
|
392
|
-
// the document at (row, col, len) found `c` where `src` said
|
|
393
|
-
// `{`. A consumer following the verification contract would
|
|
394
|
-
// refuse every such repair; one skipping it would edit the
|
|
395
|
-
// wrong token. Whatever the position names, the text names
|
|
396
|
-
// too. Twin: the same assignment in go/func.go.
|
|
397
283
|
out.site.len = this.site.len
|
|
398
284
|
out.site.src = this.site.src
|
|
399
285
|
out.path = this.path
|
|
@@ -411,7 +297,6 @@ class FuncBaseVal extends FeatureVal {
|
|
|
411
297
|
}
|
|
412
298
|
|
|
413
299
|
|
|
414
|
-
|
|
415
300
|
get canon() {
|
|
416
301
|
return '' +
|
|
417
302
|
// (this.type ? '<type>' : '') +
|
|
@@ -436,12 +321,6 @@ class FuncBaseVal extends FeatureVal {
|
|
|
436
321
|
}
|
|
437
322
|
|
|
438
323
|
|
|
439
|
-
// A function may hold its resolution for a later pass even with its
|
|
440
|
-
// arguments settled -- it then rides the ordinary args-not-done
|
|
441
|
-
// path, residuating as any unresolved call does. super() defers on a
|
|
442
|
-
// recursion residual argument (SuperFuncVal), which is why the DRIVEN
|
|
443
|
-
// arguments are passed: this.peg still holds the undriven originals
|
|
444
|
-
// at the decision point.
|
|
445
324
|
deferResolve(_ctx: AontuContext, _args?: Val[]): boolean {
|
|
446
325
|
return false
|
|
447
326
|
}
|
package/src/val/GraphAtomVal.ts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
/* Copyright (c) 2025 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
|
-
// THE GRAPH ATOMS (RELATIONS.0.md §3.3): `acyclic()` and
|
|
4
|
-
// `inverse(name)`, conjoined at the same field as the `rel()` they
|
|
5
|
-
// govern. Their model is the sizing atoms -- a property that cannot be
|
|
6
|
-
// decided while information can still arrive is HELD during
|
|
7
|
-
// unification and DECIDED at generation, where no more can.
|
|
8
|
-
//
|
|
9
|
-
// During unification they are lattice-inert: both properties are
|
|
10
|
-
// global and non-monotone (one more edge can make an acyclic graph
|
|
11
|
-
// cyclic), and the lattice guarantee -- more information never
|
|
12
|
-
// falsifies what has been observed -- forbids a constraint that could
|
|
13
|
-
// answer true and then false. So the atoms only RESIDUATE: they ride
|
|
14
|
-
// the field through meets, dedup additively, appear in canon and reach
|
|
15
|
-
// the `aon1-` hash, and REGISTER the declaration on the context. The
|
|
16
|
-
// predicate they govern is the key they sit on, evaluation-global,
|
|
17
|
-
// additive across declarations.
|
|
18
|
-
//
|
|
19
|
-
// The verdict lands at generation (relationVerdict,
|
|
20
|
-
// ts/src/relation.ts) and is reported identically by the `relations`
|
|
21
|
-
// verb -- one decision, two surfaces.
|
|
22
3
|
|
|
23
4
|
import type {
|
|
24
5
|
Val,
|
|
@@ -41,10 +22,6 @@ import { unite } from '../unify'
|
|
|
41
22
|
import { propagateMarks } from '../utility'
|
|
42
23
|
|
|
43
24
|
|
|
44
|
-
// The declarations one evaluation accumulates: predicate -> what its
|
|
45
|
-
// atoms said. Additive, exactly as two statements of one map are. The
|
|
46
|
-
// map lives on the CONTEXT (created in the constructor, like the
|
|
47
|
-
// _depth box), so every clone shares one registry.
|
|
48
25
|
export type RelDecl = {
|
|
49
26
|
acyclic?: boolean
|
|
50
27
|
inverses: Set<string>
|
|
@@ -63,10 +40,6 @@ class GraphAtomVal extends FeatureVal {
|
|
|
63
40
|
|
|
64
41
|
akind: 'acyclic' | 'inverse'
|
|
65
42
|
invname?: string
|
|
66
|
-
// The value the atom rides on -- the sizing-constraint shape: the
|
|
67
|
-
// atom ABSORBS its fold neighbours (the rel, the container, another
|
|
68
|
-
// atom) and carries them, so the fold's pairwise walk still merges
|
|
69
|
-
// the value across it. Absent until the atom meets one.
|
|
70
43
|
held?: Val
|
|
71
44
|
|
|
72
45
|
constructor(spec: ValSpec, ctx?: AontuContext) {
|
|
@@ -74,9 +47,6 @@ class GraphAtomVal extends FeatureVal {
|
|
|
74
47
|
this.akind = (spec as any).akind ?? 'acyclic'
|
|
75
48
|
this.invname = (spec as any).invname
|
|
76
49
|
this.held = (spec as any).held
|
|
77
|
-
// A settled residual, like an unmet rel(): the bare atom is its
|
|
78
|
-
// own value, and a type() body carrying one must settle. Holding
|
|
79
|
-
// an unsettled value, it is exactly as done as the value.
|
|
80
50
|
this.dc = undefined === this.held || true === this.held.done
|
|
81
51
|
? DONE : 0
|
|
82
52
|
}
|
|
@@ -90,7 +60,6 @@ class GraphAtomVal extends FeatureVal {
|
|
|
90
60
|
return out
|
|
91
61
|
}
|
|
92
62
|
|
|
93
|
-
// A rebuilt atom around a new held, at this atom's position.
|
|
94
63
|
private carry(ctx: AontuContext, held: Val): Val {
|
|
95
64
|
const out: any = new GraphAtomVal(
|
|
96
65
|
{ akind: this.akind, invname: this.invname, held } as any, ctx)
|
|
@@ -100,12 +69,6 @@ class GraphAtomVal extends FeatureVal {
|
|
|
100
69
|
return out
|
|
101
70
|
}
|
|
102
71
|
|
|
103
|
-
// The predicate is the key the atom sits on -- and a predicate is a
|
|
104
|
-
// D-1 NAME, by exactly fieldkey's rule: an atom landed anywhere
|
|
105
|
-
// else declares nothing. Registration is idempotent (the
|
|
106
|
-
// declaration set is a set) and happens at every drive, so
|
|
107
|
-
// whichever pass first sees the atom at its landed position records
|
|
108
|
-
// it.
|
|
109
72
|
register(ctx: AontuContext): void {
|
|
110
73
|
const seg = this.path[this.path.length - 1]
|
|
111
74
|
if ('string' !== typeof seg || !GRAPH_ATOM_NAME.test(seg)) {
|
|
@@ -143,11 +106,6 @@ class GraphAtomVal extends FeatureVal {
|
|
|
143
106
|
this.dc = DONE
|
|
144
107
|
return this
|
|
145
108
|
}
|
|
146
|
-
// The self-drive refines IN PLACE (the MapVal top-peer
|
|
147
|
-
// pattern): a fresh atom per pass changes object identity, so
|
|
148
|
-
// spread apply-once stamps and the entity merge's fast paths
|
|
149
|
-
// stop holding, and the enclosing bags re-open every pass --
|
|
150
|
-
// the service catalog never converged.
|
|
151
109
|
const held = unite(ctx, this.held, undefined, 'atom-drive')
|
|
152
110
|
if (true === held.isNil) {
|
|
153
111
|
return held
|
package/src/val/HideFuncVal.ts
CHANGED
|
@@ -47,21 +47,6 @@ class HideFuncVal extends FuncBaseVal {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
/*
|
|
51
|
-
unify(peer: Val, ctx: AontuContext): Val {
|
|
52
|
-
const te = ctx.explain && explainOpen(ctx, ctx.explain, 'HideFunc', this, peer)
|
|
53
|
-
let out: Val | undefined = this.resolved
|
|
54
|
-
|
|
55
|
-
if (null == out) {
|
|
56
|
-
out = this.resolve(ctx, this.peg)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
explainClose(te, out)
|
|
60
|
-
return out
|
|
61
|
-
}
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
50
|
resolve(ctx: AontuContext, args: Val[]) {
|
|
66
51
|
let out = args[0] ?? makeNilErr(ctx, 'arg', this)
|
|
67
52
|
if (!out.isNil) {
|
package/src/val/IntegerVal.ts
CHANGED
|
@@ -26,71 +26,11 @@ class IntegerVal extends ScalarVal {
|
|
|
26
26
|
isInteger = true
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
// Canon renders the EXACT digits of the value, not JavaScript's
|
|
30
|
-
// shortest round-tripping form.
|
|
31
|
-
//
|
|
32
|
-
// A JS number's toString emits the shortest decimal that parses back
|
|
33
|
-
// to the same double — at most 17 significant digits — so 2^60 printed
|
|
34
|
-
// as `1152921504606847000`, a DIFFERENT integer that merely rounds to
|
|
35
|
-
// the same double, while the Go port printed the true
|
|
36
|
-
// `1152921504606846976` from its int64. That was the one entry in the
|
|
37
|
-
// parity ledger (issue #21).
|
|
38
|
-
//
|
|
39
|
-
// Neither rendering was "the wrong number" while lossy literals were
|
|
40
|
-
// still accepted, which is why the ledger deferred to the Phase 6
|
|
41
|
-
// refusal — but Phase 6 refuses INEXACT literals, and every value in
|
|
42
|
-
// this window (2^60, 2^63-1024, …) is exactly representable and so is
|
|
43
|
-
// accepted. The divergence was never about exactness; it was about
|
|
44
|
-
// rendering. Once the value is exactly what the source asked for,
|
|
45
|
-
// there IS a right answer, and it is the exact digits.
|
|
46
|
-
//
|
|
47
|
-
// BigInt is exact here by construction: an IntegerVal's peg is
|
|
48
|
-
// integral and inside the int64 window (isIntegerKind, enforced in the
|
|
49
|
-
// constructor), so the bigint conversion cannot lose anything.
|
|
50
29
|
get canon() {
|
|
51
30
|
return integerDigits(this.peg as number)
|
|
52
31
|
}
|
|
53
32
|
|
|
54
33
|
|
|
55
|
-
// The same exactness in GENERATED output -- the other half of #21, and
|
|
56
|
-
// the half canon cannot reach.
|
|
57
|
-
//
|
|
58
|
-
// `generate()` returns NATIVE values, and the emitter sees only those:
|
|
59
|
-
// by the time exactJSON has a JS number it can no longer tell an
|
|
60
|
-
// integer-kind 2^60 (whose exact digits are the answer) from a
|
|
61
|
-
// float-kind 1e21 (whose shortest form `1e+21` is the answer, and is
|
|
62
|
-
// what Go prints too). The kind has to travel WITH the value, so above
|
|
63
|
-
// the safe-integer range an integer-kind value generates as a `bigint`,
|
|
64
|
-
// which the emitter already writes as exact digits.
|
|
65
|
-
//
|
|
66
|
-
// WHY Number.isSafeInteger IS THE LINE. It is precisely "this double is
|
|
67
|
-
// an integer that renders its own exact digits": inside the range the
|
|
68
|
-
// integers are contiguous, so toString round-trips exactly and a
|
|
69
|
-
// `number` loses nothing. Outside it they are not, and JS itself
|
|
70
|
-
// declares the value untrustworthy -- so handing back a `number` there
|
|
71
|
-
// would give a consumer something that prints wrong AND does
|
|
72
|
-
// arithmetic wrong, silently. A bigint makes both explicit: mixing it
|
|
73
|
-
// with a number throws rather than quietly rounding.
|
|
74
|
-
//
|
|
75
|
-
// The line is deliberately the WELL-KNOWN one rather than the tightest
|
|
76
|
-
// possible one. Some doubles above the range do still render exactly
|
|
77
|
-
// (2^54, say), so a predicate of `BigInt(peg).toString() === String(peg)`
|
|
78
|
-
// would keep marginally more values as `number` -- at the cost of a
|
|
79
|
-
// contract no consumer could evaluate in their head, and of handing
|
|
80
|
-
// back unsafe numbers for arithmetic. "Integers up to
|
|
81
|
-
// Number.MAX_SAFE_INTEGER are numbers; beyond that, bigints" is a rule
|
|
82
|
-
// that can be stated once and relied on.
|
|
83
|
-
//
|
|
84
|
-
// This is a BREAKING change for a consumer reading integers above 2^53
|
|
85
|
-
// out of generate() -- but those were the values that were already
|
|
86
|
-
// silently wrong, and a TypeError on `out.x + 1` is the better failure.
|
|
87
|
-
// Go needs none of this: its integer leaf is an int64, exact across the
|
|
88
|
-
// whole window, and encoding/json writes its digits.
|
|
89
|
-
//
|
|
90
|
-
// The BYTES are unchanged below the line, and the values that cross it
|
|
91
|
-
// with 17 or fewer significant digits (2^53 itself) serialise the same
|
|
92
|
-
// either way -- only their runtime type moves, which is why the `gens`
|
|
93
|
-
// rows cannot see it and ts/test/exactjson.test.ts pins it instead.
|
|
94
34
|
gen(_ctx?: AontuContext) {
|
|
95
35
|
const peg = this.peg as number
|
|
96
36
|
return Number.isSafeInteger(peg) ? peg : BigInt(peg)
|
|
@@ -108,7 +48,6 @@ class IntegerVal extends ScalarVal {
|
|
|
108
48
|
if (!isIntegerKind(spec.peg)) {
|
|
109
49
|
throw new AontuError('not-integer-kind: ' + spec.peg)
|
|
110
50
|
}
|
|
111
|
-
// super({ peg: spec.peg, kind: Integer }, ctx)
|
|
112
51
|
super({ ...spec, kind: Integer }, ctx)
|
|
113
52
|
}
|
|
114
53
|
|
package/src/val/JunctionVal.ts
CHANGED
|
@@ -33,26 +33,6 @@ abstract class JunctionVal extends FeatureVal {
|
|
|
33
33
|
|
|
34
34
|
clone(ctx: AontuContext, spec?: ValSpec): Val {
|
|
35
35
|
let out = (super.clone(ctx, spec) as JunctionVal)
|
|
36
|
-
// A JUNCTION'S MEMBERS SIT AT THE JUNCTION'S OWN POSITION. That is
|
|
37
|
-
// the rule `repathInstance` (Val.ts) states for the instance walk
|
|
38
|
-
// -- a conjunct's members occupy the conjunct's position, which is
|
|
39
|
-
// what `A & B` means -- and it holds for every clone, not only for
|
|
40
|
-
// marked ones.
|
|
41
|
-
//
|
|
42
|
-
// Val.clone's ctx cut cannot derive it: MapVal.clone hands a child
|
|
43
|
-
// its path through the SPEC rather than by descending the ctx, so
|
|
44
|
-
// a member left to the cut takes the DRIVING context's path -- the
|
|
45
|
-
// map's -- and loses the field key it sits under. A conjunct
|
|
46
|
-
// member reached through a reference into a position at least as
|
|
47
|
-
// deep as its definition then carried the entity's path, and every
|
|
48
|
-
// reader of `Val.path` was told the wrong position: a rel()-minted
|
|
49
|
-
// link took the ENTITY's key as its predicate, so `inverse(n)`
|
|
50
|
-
// looked for a mirror under a relation nobody declared and
|
|
51
|
-
// reported a written mirror missing.
|
|
52
|
-
//
|
|
53
|
-
// The instantiation flag still descends with the mark (ADR-005).
|
|
54
|
-
// Go states the same invariant directly (go/clone.go, cloneAt), so
|
|
55
|
-
// this restores parity rather than inventing a behaviour.
|
|
56
36
|
const childspec: any = spec?.mark || spec?.dup ?
|
|
57
37
|
{ mark: spec?.mark, dup: spec?.dup, path: out.path }
|
|
58
38
|
: { path: out.path }
|
package/src/val/KeyFuncVal.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Copyright (c) 2021-2025 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
import type {
|
|
6
5
|
Val,
|
|
7
6
|
ValSpec,
|
|
@@ -14,7 +13,6 @@ import {
|
|
|
14
13
|
import { StringVal } from '../val/StringVal'
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
|
|
18
16
|
import { FuncBaseVal } from './FuncBaseVal'
|
|
19
17
|
import { makeNilErr } from '../err'
|
|
20
18
|
|
|
@@ -27,7 +25,6 @@ class KeyFuncVal extends FuncBaseVal {
|
|
|
27
25
|
ctx?: AontuContext
|
|
28
26
|
) {
|
|
29
27
|
super(spec, ctx)
|
|
30
|
-
// this.dc = DONE
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
|
|
@@ -40,34 +37,12 @@ class KeyFuncVal extends FuncBaseVal {
|
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
|
|
43
|
-
// `key()` is the first value to take THE STAGING RULE (G8 phase 0,
|
|
44
|
-
// see AontuContext.settle): its answer is a segment of its own path,
|
|
45
|
-
// so it must not answer while a spread, a reference or a `move` can
|
|
46
|
-
// still move it. It residuates until the model stops changing, and
|
|
47
|
-
// fires on the settle pass. The residuation itself is FuncBaseVal's,
|
|
48
|
-
// shared with the generation combinators.
|
|
49
40
|
staged = true
|
|
50
41
|
|
|
51
42
|
|
|
52
43
|
resolve(ctx: AontuContext, _args: Val[]) {
|
|
53
44
|
let out: Val = this
|
|
54
45
|
|
|
55
|
-
// if (!this.mark.type && !this.mark.hide) {
|
|
56
|
-
//
|
|
57
|
-
// THE LEVEL MUST BE AN INTEGER, OR ABSENT.
|
|
58
|
-
//
|
|
59
|
-
// A level is an index into the path (0 the own key, the default 1 the
|
|
60
|
-
// parent), so the argument is an integer or it is a mistake. Both
|
|
61
|
-
// exact integer leaves qualify -- `integer` and `biginteger` -- and
|
|
62
|
-
// everything else is refused rather than silently meaning "parent",
|
|
63
|
-
// which is what made a mistyped level undetectable.
|
|
64
|
-
//
|
|
65
|
-
// This also removes a crash. The test used to be
|
|
66
|
-
// `isNaN(move) ? 1 : +move` with the COERCING global isNaN, which is
|
|
67
|
-
// ToNumber, and ToNumber THROWS for a bigint (a biginteger's peg) and
|
|
68
|
-
// for the null-prototype object a map's peg is -- neither has a
|
|
69
|
-
// toString or valueOf to call. The exception escaped into unify's
|
|
70
|
-
// catch-all and surfaced as an opaque [aontu/internal].
|
|
71
46
|
const argval: any = this.peg?.[0]
|
|
72
47
|
let move = 1
|
|
73
48
|
|
|
@@ -86,28 +61,6 @@ class KeyFuncVal extends FuncBaseVal {
|
|
|
86
61
|
}
|
|
87
62
|
}
|
|
88
63
|
|
|
89
|
-
// THE PATH IS THE ONE IT IS BEING DRIVEN AT, not the one it
|
|
90
|
-
// remembers. `this.path` is a cache that the residuation clone
|
|
91
|
-
// refreshes each pass, and it is right for a key() the bag walk
|
|
92
|
-
// reaches directly -- but a key() nested inside a function or
|
|
93
|
-
// operator ARGUMENT is never reached that way: it is driven by its
|
|
94
|
-
// enclosing call, which re-paths nothing, so it kept the position
|
|
95
|
-
// the SOURCE TEXT put it at. Inside a template that is fatal: the
|
|
96
|
-
// source position of `&: {k: "x" + key()}` (or of `pack`'s
|
|
97
|
-
// template) is the template, not any of the destinations, and the
|
|
98
|
-
// parse-time path of a function argument is not a document
|
|
99
|
-
// position at all.
|
|
100
|
-
// A stored path is only usable if it IS one: a path segment that is
|
|
101
|
-
// not a key is not a position, and the parse-time path of a value
|
|
102
|
-
// written inside a function ARGUMENT carries exactly that -- the
|
|
103
|
-
// argument has no key, so its segment is not a string. Those values
|
|
104
|
-
// are also the ones the bag walk never re-paths (a call re-paths
|
|
105
|
-
// nothing it holds), which is why the stored path stays wrong
|
|
106
|
-
// forever rather than being refreshed on the next pass. For them
|
|
107
|
-
// the driving context is the only truth. For everything else the
|
|
108
|
-
// stored path stays authoritative, because a TRANSPLANTED value
|
|
109
|
-
// (move(), a shared clone) must answer for where it was put, not
|
|
110
|
-
// for whichever driver happened to reach it first.
|
|
111
64
|
let positioned = true
|
|
112
65
|
for (const seg of this.path) {
|
|
113
66
|
if ('string' !== typeof seg) {
|
|
@@ -118,7 +71,6 @@ class KeyFuncVal extends FuncBaseVal {
|
|
|
118
71
|
|
|
119
72
|
const here = positioned ? this.path : ctx.path
|
|
120
73
|
const key = here[here.length - (1 + move)] ?? ''
|
|
121
|
-
// console.log('KEY', this.path, move, key)
|
|
122
74
|
|
|
123
75
|
out = new StringVal({ peg: key })
|
|
124
76
|
// }
|