hclang 0.38.2 → 0.39.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/esm/lib/bundle/hc-sources.js +65 -55
- package/esm/lib/execute/eval-pipe.js +1 -2
- package/esm/lib/frames/bound-method.js +2 -2
- package/esm/lib/frames/frame-expr.js +4 -2
- package/esm/lib/frames/frame-name.js +1 -3
- package/esm/lib/frames/frame-note.js +1 -8
- package/esm/lib/frames/frame-scope-anchor.js +17 -0
- package/esm/lib/frames/frame.js +2 -2
- package/esm/lib/ops/math.js +8 -9
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -1412,7 +1412,7 @@ export const HC_SOURCES = new Map([
|
|
|
1412
1412
|
"when odd, right next. It is a Count rather than all or nil because a field",
|
|
1413
1413
|
"cannot hold nil, and a Count keeps the odd phase present: a Demi in phase 1 is",
|
|
1414
1414
|
"a value, unlike the nil `.####` answers for a Frame with no Demi. Anything else",
|
|
1415
|
-
"is refused with
|
|
1415
|
+
"is refused with `$!.invalid-demi`, a named error, as Figures refuses an",
|
|
1416
1416
|
"unsupported host. The fields are the whole state, so two Demis are `=` exactly",
|
|
1417
1417
|
"when their fields are.",
|
|
1418
1418
|
"",
|
|
@@ -1445,7 +1445,7 @@ export const HC_SOURCES = new Map([
|
|
|
1445
1445
|
"count lexically (spec a06). What a branch needs is bound as a local at method",
|
|
1446
1446
|
"level, where nested blocks read it.",
|
|
1447
1447
|
"```",
|
|
1448
|
-
".Demi {.p (
|
|
1448
|
+
".Demi {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.p (__ .0); .l (__ .1); .r (__ .2);",
|
|
1449
1449
|
" ((((p = 2) : {p = 1}) ? {p ~ (0.<>)}) ? {(l ~ (0.<>)) ? {r ~ (0.<>)}}) ? {[",
|
|
1450
1450
|
" .phase p;",
|
|
1451
1451
|
" .left l;",
|
|
@@ -1456,9 +1456,9 @@ export const HC_SOURCES = new Map([
|
|
|
1456
1456
|
" .apply_ {.s (_ .##); .l (_^ .left); .r (_^ .right);",
|
|
1457
1457
|
" (s ~ (0.<>)) ? {((_^^ .phase) = 2) ? {@left (l + s); @phase 1;} : {@right (r + s); @phase 2;}; _^^} : {s}};",
|
|
1458
1458
|
" .scale_ {.k _; .l (_^ .left); .r (_^ .right);",
|
|
1459
|
-
" (k ~ (0.<>)) ? {@left (l * k); @right (r * k); _^^} : {invalid-scale}};",
|
|
1459
|
+
" (k ~ (0.<>)) ? {@left (l * k); @right (r * k); _^^} : {$!.invalid-scale}};",
|
|
1460
1460
|
" .toText {“Demi(” (((_^ .phase) = 2) ? {“<>”} : {“()”}) “,” (_^ .left) “,” (_^ .right) “)”}",
|
|
1461
|
-
" ]} : {invalid-demi}};",
|
|
1461
|
+
" ]} : {$!.invalid-demi}} : {$!.invalid-demi}};",
|
|
1462
1462
|
"```",
|
|
1463
1463
|
"## Construction",
|
|
1464
1464
|
"",
|
|
@@ -1475,9 +1475,9 @@ export const HC_SOURCES = new Map([
|
|
|
1475
1475
|
"Anything but three Counts with phase 1 or 2 is refused",
|
|
1476
1476
|
"```",
|
|
1477
1477
|
"; Demi [3, 0, 0]",
|
|
1478
|
-
"# $!.
|
|
1478
|
+
"# $!.invalid-demi",
|
|
1479
1479
|
"; [Demi [2, (0 - 1), 0], Demi [2, (5 - 3), 0], Demi [2, 0], Demi 5, Demi [(5 - 3), 0, 0]]",
|
|
1480
|
-
"# [$!.
|
|
1480
|
+
"# [$!.invalid-demi, $!.invalid-demi, $!.invalid-demi, $!.invalid-demi, $!.invalid-demi]",
|
|
1481
1481
|
"```",
|
|
1482
1482
|
"## Application",
|
|
1483
1483
|
"",
|
|
@@ -1608,7 +1608,7 @@ export const HC_SOURCES = new Map([
|
|
|
1608
1608
|
"; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6)]",
|
|
1609
1609
|
"# [“Demi((),24,6)”, “Demi((),0,0)”, <>, <>]",
|
|
1610
1610
|
"; e.scale_ (0 - 2)",
|
|
1611
|
-
"# $!.
|
|
1611
|
+
"# $!.invalid-scale",
|
|
1612
1612
|
"```",
|
|
1613
1613
|
"It is the shadow of Star on a nonempty host",
|
|
1614
1614
|
"```",
|
|
@@ -1626,13 +1626,16 @@ export const HC_SOURCES = new Map([
|
|
|
1626
1626
|
"Carets count lexically, so inside a branch `_^` is the method's own scope, not",
|
|
1627
1627
|
"the receiver. Reading a load there fails, `$!.name-missing`. Before 011.20,",
|
|
1628
1628
|
"`+` turned that failure into nil, and writing nil leaves a field as it was, so",
|
|
1629
|
-
"the deposit silently did nothing while the phase still flipped.
|
|
1630
|
-
"failure
|
|
1629
|
+
"the deposit silently did nothing while the phase still flipped. Since #467 the",
|
|
1630
|
+
"failure is the method's answer and ends it at the failed write, so even through",
|
|
1631
|
+
"a mutable name neither field changes",
|
|
1631
1632
|
"```",
|
|
1632
1633
|
"; .Wrong {[.phase 2; .left 0; .apply_ {.s (_ .##); (_^.phase = 2) ? {@left (_^.left + s); @phase 1;};}]};",
|
|
1633
|
-
"; .
|
|
1634
|
-
";
|
|
1635
|
-
"#
|
|
1634
|
+
"; .w_ (Wrong ());",
|
|
1635
|
+
"; w_ 5",
|
|
1636
|
+
"# $!.name-missing “...",
|
|
1637
|
+
"; [w_.phase, w_.left]",
|
|
1638
|
+
"# [2, 0]",
|
|
1636
1639
|
"; .Right {[.phase 2; .left 0; .apply_ {.s (_ .##); (_^.phase = 2) ? {@left (_^^.left + s); @phase 1;};}]};",
|
|
1637
1640
|
"; .r ((Right ()) 5);",
|
|
1638
1641
|
"; [r.phase, r.left]",
|
|
@@ -1698,7 +1701,7 @@ export const HC_SOURCES = new Map([
|
|
|
1698
1701
|
"```",
|
|
1699
1702
|
".gap {.x _; (x.###) ? {",
|
|
1700
1703
|
" .signed (x.###);",
|
|
1701
|
-
" (signed .< 0) ? {0 - signed} : {signed}} : {unsupported-figure}};",
|
|
1704
|
+
" (signed .< 0) ? {0 - signed} : {signed}} : {$!.unsupported-figure}};",
|
|
1702
1705
|
"```",
|
|
1703
1706
|
"Spin retains a typed positive Count divisor. Bare `x.### / N` would accept",
|
|
1704
1707
|
"negative or fractional divisors and silently answer nil for an unsupported",
|
|
@@ -1710,7 +1713,7 @@ export const HC_SOURCES = new Map([
|
|
|
1710
1713
|
" (host.###) ? {",
|
|
1711
1714
|
" {.n <(1).<>> _; .signed (host.###);",
|
|
1712
1715
|
" (n .< 1) ? {signed / 0} : {signed / n}}} : {",
|
|
1713
|
-
" {.n _; unsupported-figure}}};",
|
|
1716
|
+
" {.n _; $!.unsupported-figure}}};",
|
|
1714
1717
|
"```",
|
|
1715
1718
|
"Native construction, counting and comparisons need no module helpers.",
|
|
1716
1719
|
"```",
|
|
@@ -1726,7 +1729,7 @@ export const HC_SOURCES = new Map([
|
|
|
1726
1729
|
"```",
|
|
1727
1730
|
"; [([].### ? {<>} : {()}), ([[], [[]]].### ? {<>} : {()}), ([[], 5].### ? {<>} : {()}), ([.k 1; []].### ? {<>} : {()})]",
|
|
1728
1731
|
"# [<>, <>, <>, <>]",
|
|
1729
|
-
"; [(e.### ? {e} : {unsupported-figure}) = e, (e.### ? {e} : {unsupported-figure}) === e]",
|
|
1732
|
+
"; [(e.### ? {e} : {$!.unsupported-figure}) = e, (e.### ? {e} : {$!.unsupported-figure}) === e]",
|
|
1730
1733
|
"# [<>, <>]",
|
|
1731
1734
|
"; [[], “a”] * [[]]",
|
|
1732
1735
|
"# $!.star-domain *",
|
|
@@ -2537,7 +2540,8 @@ export const HC_SOURCES = new Map([
|
|
|
2537
2540
|
"array's properties are configuration, not routed Frames, so the constructor",
|
|
2538
2541
|
"keeps the elements in a fresh array of its own, and a channel argument that",
|
|
2539
2542
|
"declares `apply` cannot change what appending means. Anything else is refused",
|
|
2540
|
-
"with
|
|
2543
|
+
"with `$!.invalid-router`, a named error, as `Demi` refuses with",
|
|
2544
|
+
"`$!.invalid-demi`.",
|
|
2541
2545
|
"Any phase and any two channels are a state; nothing requires the channels to",
|
|
2542
2546
|
"be a history the router could have produced.",
|
|
2543
2547
|
"",
|
|
@@ -2573,7 +2577,7 @@ export const HC_SOURCES = new Map([
|
|
|
2573
2577
|
"the method body. What a branch needs is bound as a local at method level.",
|
|
2574
2578
|
"```",
|
|
2575
2579
|
".channel-load {.c _; (c.# = 0) ? {0} : {c.##}};",
|
|
2576
|
-
".RotorRouter {.p (
|
|
2580
|
+
".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.p (__ .0); .l (__ .1); .r (__ .2);",
|
|
2577
2581
|
" ((((p = 2) : {p = 1}) ? {p ~ (0.<>)}) ? {(l ~ ([].<>)) ? {r ~ ([].<>)}}) ? {[",
|
|
2578
2582
|
" .phase p;",
|
|
2579
2583
|
" .left (l | []);",
|
|
@@ -2584,7 +2588,7 @@ export const HC_SOURCES = new Map([
|
|
|
2584
2588
|
" .## {(channel-load (_^ .left)) + (channel-load (_^ .right))};",
|
|
2585
2589
|
" .### {(channel-load (_^ .left)) - (channel-load (_^ .right))};",
|
|
2586
2590
|
" .toText {“RotorRouter(” (((_^ .phase) = 2) ? {“<>”} : {“()”}) “,” (_^ .left) “,” (_^ .right) “)”}",
|
|
2587
|
-
" ]} : {invalid-router}};",
|
|
2591
|
+
" ]} : {$!.invalid-router}} : {$!.invalid-router}};",
|
|
2588
2592
|
"```",
|
|
2589
2593
|
"## Construction",
|
|
2590
2594
|
"",
|
|
@@ -2598,9 +2602,9 @@ export const HC_SOURCES = new Map([
|
|
|
2598
2602
|
"Anything but a phase of 1 or 2 and two arrays is refused",
|
|
2599
2603
|
"```",
|
|
2600
2604
|
"; RotorRouter [3, [], []]",
|
|
2601
|
-
"# $!.
|
|
2605
|
+
"# $!.invalid-router",
|
|
2602
2606
|
"; [RotorRouter [(5 - 3), [], []], RotorRouter [2, [], 5], RotorRouter [2, (1, 2), []], RotorRouter [2, []], RotorRouter 5]",
|
|
2603
|
-
"# [$!.
|
|
2607
|
+
"# [$!.invalid-router, $!.invalid-router, $!.invalid-router, $!.invalid-router, $!.invalid-router]",
|
|
2604
2608
|
"```",
|
|
2605
2609
|
"A channel is its elements. The router keeps them in an array of its own, so a",
|
|
2606
2610
|
"channel's properties and a declared `apply` do not come with it",
|
|
@@ -2714,16 +2718,13 @@ export const HC_SOURCES = new Map([
|
|
|
2714
2718
|
"; counter_.n",
|
|
2715
2719
|
"# 2",
|
|
2716
2720
|
"```",
|
|
2717
|
-
"
|
|
2718
|
-
"
|
|
2719
|
-
"
|
|
2721
|
+
"An error is the answer of the expression that applies the router, so it is",
|
|
2722
|
+
"never routed. A diagnostic failure such as a missing name is an error too",
|
|
2723
|
+
"(#467), so it is not routed either",
|
|
2720
2724
|
"```",
|
|
2721
2725
|
"; r0 (1 / 0)",
|
|
2722
2726
|
"# $!.division-by-zero /",
|
|
2723
|
-
";
|
|
2724
|
-
"; [noted.phase, noted.left.#]",
|
|
2725
|
-
"# [1, 1]",
|
|
2726
|
-
"; noted.####",
|
|
2727
|
+
"; r0 ([].nope)",
|
|
2727
2728
|
"# $!.name-missing “...",
|
|
2728
2729
|
"```",
|
|
2729
2730
|
"Routing nil routes nothing",
|
|
@@ -2844,13 +2845,17 @@ export const HC_SOURCES = new Map([
|
|
|
2844
2845
|
"# [1, 1, 9, []]",
|
|
2845
2846
|
"```",
|
|
2846
2847
|
"Carets count lexically (spec a06). Inside a branch, `_^` is the method's own",
|
|
2847
|
-
"scope, so a router that reads its channel there reads nothing
|
|
2848
|
-
"
|
|
2848
|
+
"scope, so a router that reads its channel there reads nothing. That failure is",
|
|
2849
|
+
"the method's answer and ends it at the failed write (#467), so even through a",
|
|
2850
|
+
"mutable name the router is unchanged. `_^^` is the receiver from inside the",
|
|
2851
|
+
"branch",
|
|
2849
2852
|
"```",
|
|
2850
2853
|
"; .WrongRouter {[.phase 2; .left []; .apply_ {.x _; ((_^ .phase) = 2) ? {@left (_^ .left x); @phase 1;};}]};",
|
|
2851
|
-
"; .
|
|
2852
|
-
";
|
|
2853
|
-
"#
|
|
2854
|
+
"; .w_ (WrongRouter ());",
|
|
2855
|
+
"; w_ 5",
|
|
2856
|
+
"# $!.name-missing “...",
|
|
2857
|
+
"; [w_.phase, w_.left]",
|
|
2858
|
+
"# [2, []]",
|
|
2854
2859
|
"; .RightRouter {[.phase 2; .left []; .apply_ {.x _; ((_^ .phase) = 2) ? {@left (_^^ .left x); @phase 1;};}]};",
|
|
2855
2860
|
"; .rr ((RightRouter ()) 5);",
|
|
2856
2861
|
"; [rr.phase, rr.left]",
|
|
@@ -2904,7 +2909,7 @@ export const HC_SOURCES = new Map([
|
|
|
2904
2909
|
"# ````",
|
|
2905
2910
|
"; ``````",
|
|
2906
2911
|
"# ``````",
|
|
2907
|
-
"
|
|
2912
|
+
"```## A document publishes its characters without its fences```",
|
|
2908
2913
|
"; `one-backtick document`.body",
|
|
2909
2914
|
"# “one-backtick document”",
|
|
2910
2915
|
"; ```body with `one` and ``two`` spans```.body",
|
|
@@ -2954,29 +2959,29 @@ export const HC_SOURCES = new Map([
|
|
|
2954
2959
|
"```",
|
|
2955
2960
|
"Test types",
|
|
2956
2961
|
"```",
|
|
2957
|
-
"
|
|
2962
|
+
"```## Empty schema accepts any value```",
|
|
2958
2963
|
"; .x <> 42",
|
|
2959
2964
|
"# 42",
|
|
2960
|
-
"
|
|
2965
|
+
"```## Number enumerations```",
|
|
2961
2966
|
"; .option <1,2,3> 2",
|
|
2962
2967
|
"# .option 2",
|
|
2963
2968
|
"; @option 3",
|
|
2964
2969
|
"# 3",
|
|
2965
2970
|
"; @option 4",
|
|
2966
2971
|
"# $!.type-error .option <1, 2, 3> 4",
|
|
2967
|
-
"
|
|
2972
|
+
"```## Single value schema (constant)```",
|
|
2968
2973
|
"; .const <42> 42",
|
|
2969
2974
|
"# .const 42",
|
|
2970
2975
|
"; @const 43",
|
|
2971
2976
|
"# $!.type-error .const <42> 43",
|
|
2972
|
-
"
|
|
2977
|
+
"```## Multiple valid assignments```",
|
|
2973
2978
|
"; .x <1,2> 1",
|
|
2974
2979
|
"# 1",
|
|
2975
2980
|
"; @x 2",
|
|
2976
2981
|
"# 2",
|
|
2977
2982
|
"; @x 1",
|
|
2978
2983
|
"# 1",
|
|
2979
|
-
"
|
|
2984
|
+
"```## Original tests```",
|
|
2980
2985
|
"; <> 1",
|
|
2981
2986
|
"# <>",
|
|
2982
2987
|
"; <> ()",
|
|
@@ -2985,7 +2990,7 @@ export const HC_SOURCES = new Map([
|
|
|
2985
2990
|
"# .one 1",
|
|
2986
2991
|
"; @one 2",
|
|
2987
2992
|
"# $!.type-error .one <1> 2",
|
|
2988
|
-
"
|
|
2993
|
+
"```## Boolean and first-class type operations```",
|
|
2989
2994
|
"; ().!",
|
|
2990
2995
|
"# <>",
|
|
2991
2996
|
"; <>.!",
|
|
@@ -2998,7 +3003,7 @@ export const HC_SOURCES = new Map([
|
|
|
2998
3003
|
"# <>",
|
|
2999
3004
|
"; “Q” ~ (1).<>",
|
|
3000
3005
|
"# ()",
|
|
3001
|
-
"
|
|
3006
|
+
"```## Closure signatures apply defaults, require bare fields, and allow extras```",
|
|
3002
3007
|
"; .join-name (.first “Jane”, .last) ^ {last “, ” first};",
|
|
3003
3008
|
"; join-name (.first “John”, .last “Doe”)",
|
|
3004
3009
|
"# “Doe, John”",
|
|
@@ -3009,7 +3014,7 @@ export const HC_SOURCES = new Map([
|
|
|
3009
3014
|
"```",
|
|
3010
3015
|
"Conditionals",
|
|
3011
3016
|
"```",
|
|
3012
|
-
"
|
|
3017
|
+
"```## Binary truth table for ordinary frames and raw nil: `:` answers a frame itself```",
|
|
3013
3018
|
"; 1 ? {2 + 2}",
|
|
3014
3019
|
"# 4",
|
|
3015
3020
|
"; 1 : {2 + 2}",
|
|
@@ -3018,12 +3023,12 @@ export const HC_SOURCES = new Map([
|
|
|
3018
3023
|
"# ()",
|
|
3019
3024
|
"; () : {2 + 2}",
|
|
3020
3025
|
"# 4",
|
|
3021
|
-
"
|
|
3026
|
+
"```## The selected callable may itself return nil```",
|
|
3022
3027
|
"; 1 ? {()}",
|
|
3023
3028
|
"# ()",
|
|
3024
3029
|
"; () : {()}",
|
|
3025
3030
|
"# ()",
|
|
3026
|
-
"
|
|
3031
|
+
"```## Dotted comparisons produce Frame.all or Frame.nil predicates```",
|
|
3027
3032
|
"; 1.> 5 ? {100}",
|
|
3028
3033
|
"# ()",
|
|
3029
3034
|
"; 1.> 5 : {10}",
|
|
@@ -3032,52 +3037,52 @@ export const HC_SOURCES = new Map([
|
|
|
3032
3037
|
"# 100",
|
|
3033
3038
|
"; 5.> 1 : {10}",
|
|
3034
3039
|
"# <>",
|
|
3035
|
-
"
|
|
3040
|
+
"```## Chained conditionals answer the taken branch```",
|
|
3036
3041
|
"; 1.> 5 ? (2 * 50) : 10",
|
|
3037
3042
|
"# 10",
|
|
3038
3043
|
"; 5.> 1 ? (2 * 50) : 10",
|
|
3039
3044
|
"# 100",
|
|
3040
|
-
"
|
|
3045
|
+
"```## A taken branch that answers nil falls through to the else branch```",
|
|
3041
3046
|
"; 5.> 1 ? {()} : {10}",
|
|
3042
3047
|
"# 10",
|
|
3043
3048
|
"```",
|
|
3044
3049
|
"Figures: construct with optional children, observe with Figure answers",
|
|
3045
3050
|
"```",
|
|
3046
3051
|
"; .A []; .B [A]; .E [A, B]; .B2 [A];",
|
|
3047
|
-
"
|
|
3052
|
+
"```## Reuse and resemblance are different rungs of the equality ladder```",
|
|
3048
3053
|
"; [B = B2, B == B2, B === B2]",
|
|
3049
3054
|
"# [<>, <>, ()]",
|
|
3050
3055
|
"; (E .0) === A",
|
|
3051
3056
|
"# <>",
|
|
3052
|
-
"
|
|
3057
|
+
"```## A plain conditional answers a Figure from either branch```",
|
|
3053
3058
|
"; .same {((_ .0) === (_ .1)) ? {B} : {A}};",
|
|
3054
3059
|
"; same [B, B]",
|
|
3055
3060
|
"# [[]]",
|
|
3056
3061
|
"; same [B, B2]",
|
|
3057
3062
|
"# []",
|
|
3058
|
-
"
|
|
3063
|
+
"```## Box a branch that answers nil, so it does not fall through```",
|
|
3059
3064
|
"; .rest {((_ && {(((_ .0) = .0) ? {[()]} : {[[__ .1]]}) .0}) | []) & {_ .0}};",
|
|
3060
3065
|
"; rest E",
|
|
3061
3066
|
"# [[[]]]",
|
|
3062
|
-
"
|
|
3067
|
+
"```## Observing a Figure through a plain name does not write onto it```",
|
|
3063
3068
|
"; E & {.o _; o};",
|
|
3064
3069
|
"; E",
|
|
3065
3070
|
"# [[], [[]]]",
|
|
3066
3071
|
"```",
|
|
3067
3072
|
"Quote delimiters",
|
|
3068
3073
|
"```",
|
|
3069
|
-
"
|
|
3074
|
+
"```## Curly quotes nest without an escape character```",
|
|
3070
3075
|
"; “a “b” c”",
|
|
3071
3076
|
"# “a “b” c”",
|
|
3072
|
-
"
|
|
3077
|
+
"```## The ASCII quote is an input spelling of the same value```",
|
|
3073
3078
|
'; "ascii"',
|
|
3074
3079
|
"# “ascii”",
|
|
3075
3080
|
'; ""',
|
|
3076
3081
|
"# “”",
|
|
3077
|
-
"
|
|
3082
|
+
"```## An odd ASCII run selects nesting depth, so shorter runs are content```",
|
|
3078
3083
|
'; """x "" y"""',
|
|
3079
3084
|
'# “x "" y”',
|
|
3080
|
-
"
|
|
3085
|
+
"```## Single quotes name a resource without authorizing it```",
|
|
3081
3086
|
"; 'jsr:@swanfactory/hclang'",
|
|
3082
3087
|
"# 'jsr:@swanfactory/hclang'",
|
|
3083
3088
|
"; 'jsr:@swanfactory/hclang'.scheme",
|
|
@@ -3331,13 +3336,18 @@ export const HC_SOURCES = new Map([
|
|
|
3331
3336
|
"# <>",
|
|
3332
3337
|
"; 9.80.m == 9.8.m",
|
|
3333
3338
|
"# <>",
|
|
3334
|
-
"; 3.m == 3.0.m",
|
|
3335
|
-
"# ()",
|
|
3336
3339
|
"; 9.8.m = 9.8.kg",
|
|
3337
3340
|
"# ()",
|
|
3338
3341
|
"; 9.8.m = 9.8",
|
|
3339
3342
|
"# ()",
|
|
3340
3343
|
"```",
|
|
3344
|
+
"A Count literal has no unit suffix: `3.m` reads a missing property, so comparing",
|
|
3345
|
+
"it propagates that failure rather than answering nil. Use `3.0.m` for a typed",
|
|
3346
|
+
"number.",
|
|
3347
|
+
"```",
|
|
3348
|
+
"; 3.m == 3.0.m",
|
|
3349
|
+
"# $!.name-missing “...",
|
|
3350
|
+
"```",
|
|
3341
3351
|
"`===` asks for the same frame, and an atom owns no identity, so it is `==`:",
|
|
3342
3352
|
"different units are never the same (#358)",
|
|
3343
3353
|
"```",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvaluationScope, Frame, FrameGroup,
|
|
1
|
+
import { EvaluationScope, Frame, FrameGroup, NilContext, } from "../frames.js";
|
|
2
2
|
import { LexPipe } from "./lex-pipe.js";
|
|
3
3
|
import { ParsePipe } from "./parse-pipe.js";
|
|
4
4
|
/** Builds the shared Lex/Parse/Eval pipeline for one HC source unit. */
|
|
@@ -87,6 +87,5 @@ function outputFailed(result, seen) {
|
|
|
87
87
|
return false;
|
|
88
88
|
seen.add(result);
|
|
89
89
|
return result.isFailedResult() ||
|
|
90
|
-
(result instanceof FrameNote && result.isDiagnosticFailure()) ||
|
|
91
90
|
result.asArray().some((item) => outputFailed(item, seen));
|
|
92
91
|
}
|
|
@@ -104,8 +104,8 @@ export class BoundMethod extends Frame {
|
|
|
104
104
|
// was built last, so a method would read another instance's fields.
|
|
105
105
|
const result = this.method.call(argument, Frame.nil, state);
|
|
106
106
|
// A mutating method answers its receiver, unless it answered an error. A
|
|
107
|
-
// diagnostic
|
|
108
|
-
//
|
|
107
|
+
// diagnostic failure such as `$!.name-missing` carries the same flag.
|
|
108
|
+
// Preserve referent checks for programmatic reference wrappers (011.20).
|
|
109
109
|
if (result.isFailedResult() || result.referent().isError())
|
|
110
110
|
return result;
|
|
111
111
|
return this.isMutating() ? state.receiver : result;
|
|
@@ -106,8 +106,10 @@ export class FrameExpr extends FrameList {
|
|
|
106
106
|
return terms.reduce((sum, item, index) => {
|
|
107
107
|
// A failed term is the result of the expression. In particular, a
|
|
108
108
|
// missing dot-parameter read must not be replaced by the operator or
|
|
109
|
-
// operand that follows it.
|
|
110
|
-
|
|
109
|
+
// operand that follows it. Only the value itself counts: an aggregate
|
|
110
|
+
// that collected a failure is still an ordinary value its later terms
|
|
111
|
+
// can read (`[E, 7] .1` is 7), as it was before #467 flagged notes.
|
|
112
|
+
if (sum.isError())
|
|
111
113
|
return sum;
|
|
112
114
|
const value = item.in(resumedScope(item, scope));
|
|
113
115
|
if (value.is.error === true)
|
|
@@ -85,9 +85,7 @@ export class FrameName extends FrameAtom {
|
|
|
85
85
|
const target = scope.parameterAt(this.source.length + 1);
|
|
86
86
|
if (target)
|
|
87
87
|
return target;
|
|
88
|
-
|
|
89
|
-
missing.is.error = true;
|
|
90
|
-
return missing;
|
|
88
|
+
return FrameNote.key(this.toString(), this);
|
|
91
89
|
}
|
|
92
90
|
// Construction declares the new aggregate's parent. Method-position `.^`
|
|
93
91
|
// instead re-parents the exact original-or-copy target authorized by the
|
|
@@ -48,17 +48,10 @@ export class FrameNote extends FrameAtom {
|
|
|
48
48
|
});
|
|
49
49
|
this.up = where;
|
|
50
50
|
this.is.note = true;
|
|
51
|
+
this.is.error = this.isDiagnosticFailure();
|
|
51
52
|
this.setLabel(data, source);
|
|
52
53
|
this.id += this.data;
|
|
53
54
|
}
|
|
54
|
-
/** A diagnostic failure is an error value, though not flagged as one. */
|
|
55
|
-
isError() {
|
|
56
|
-
return super.isError() || this.isDiagnosticFailure();
|
|
57
|
-
}
|
|
58
|
-
/** Observations preserve diagnostic failures as values. */
|
|
59
|
-
observationError() {
|
|
60
|
-
return this.isDiagnosticFailure() ? this : super.observationError();
|
|
61
|
-
}
|
|
62
55
|
/** Diagnostic notes that represent failures, rather than test progress. */
|
|
63
56
|
isDiagnosticFailure() {
|
|
64
57
|
return ["!", "<>", ">", "-"].includes(this.data);
|
|
@@ -13,6 +13,10 @@ const invalidDollar = (source, char = "") => ({
|
|
|
13
13
|
disposition: ScanDisposition.Error,
|
|
14
14
|
message: `invalid dollar form: $${source}${char === "\n" ? "\\n" : char}`,
|
|
15
15
|
});
|
|
16
|
+
/** A named error is a source atom; its flag is not a lexical failure. */
|
|
17
|
+
const namedError = (source) => /^[A-Za-z_][A-Za-z0-9_-]*$/.test(source.slice(2))
|
|
18
|
+
? complete(Frame.error(`$${source}`))
|
|
19
|
+
: invalidDollar(source);
|
|
16
20
|
/** A boundary starts another token rather than extending a dollar form. */
|
|
17
21
|
const isBoundary = (char) => !/[$\w-]/.test(char);
|
|
18
22
|
/**
|
|
@@ -47,6 +51,17 @@ const recognizeDollar = (symbol, source = "") => {
|
|
|
47
51
|
? { disposition: ScanDisposition.Consume }
|
|
48
52
|
: invalidDollar(source, char);
|
|
49
53
|
}
|
|
54
|
+
if (source === "!" && char === ".") {
|
|
55
|
+
return { disposition: ScanDisposition.Consume };
|
|
56
|
+
}
|
|
57
|
+
if (source.startsWith("!.")) {
|
|
58
|
+
const accepted = source.length === 2
|
|
59
|
+
? /^[A-Za-z_]$/.test(char)
|
|
60
|
+
: /^[A-Za-z0-9_-]$/.test(char);
|
|
61
|
+
return accepted
|
|
62
|
+
? { disposition: ScanDisposition.Consume }
|
|
63
|
+
: namedError(source);
|
|
64
|
+
}
|
|
50
65
|
if (char === FrameNote.NOTE_END) {
|
|
51
66
|
return { disposition: ScanDisposition.CompleteRedispatch };
|
|
52
67
|
}
|
|
@@ -59,6 +74,8 @@ const finishDollar = (source = "") => {
|
|
|
59
74
|
return complete(FrameScopeAnchor.host());
|
|
60
75
|
if (source === "<")
|
|
61
76
|
return invalidDollar(source);
|
|
77
|
+
if (source.startsWith("!."))
|
|
78
|
+
return namedError(source);
|
|
62
79
|
return {
|
|
63
80
|
disposition: ScanDisposition.Error,
|
|
64
81
|
message: `unterminated FrameNote: $${source}`,
|
package/esm/lib/frames/frame.js
CHANGED
|
@@ -664,8 +664,8 @@ export class Frame extends MetaFrame {
|
|
|
664
664
|
return this;
|
|
665
665
|
}
|
|
666
666
|
/**
|
|
667
|
-
* Whether this value is itself an error
|
|
668
|
-
*
|
|
667
|
+
* Whether this value is itself an error, flagged as such. A diagnostic
|
|
668
|
+
* failure such as `$!.name-missing` is flagged when constructed (#467).
|
|
669
669
|
* Unlike `isFailedResult`, it never looks inside an aggregate, and unlike
|
|
670
670
|
* `observationError`, a non-finite number or a cycle is not one: those fail
|
|
671
671
|
* to be measured, not to be computed (011.20).
|
package/esm/lib/ops/math.js
CHANGED
|
@@ -14,8 +14,7 @@ const numeric = (source, block, operation) => {
|
|
|
14
14
|
* than nil, so a failed read such as `$!.name-missing` reaches whatever uses
|
|
15
15
|
* the result. As nil it vanished: a write of nil leaves a field unchanged, so a
|
|
16
16
|
* misread load looked like an update that never landed (011.20). Ordering
|
|
17
|
-
*
|
|
18
|
-
* that answered one would take the branch.
|
|
17
|
+
* uses the same rule: diagnostic failures now short-circuit before `?` (#467).
|
|
19
18
|
*/
|
|
20
19
|
const arithmetic = (source, block, operation) => failure(source) ?? failure(block) ?? numeric(source, block, operation);
|
|
21
20
|
/** An operand that is an error value (`Frame.isError`), unwrapped. */
|
|
@@ -45,17 +44,17 @@ export const Divide = (source, block) => arithmetic(source, block, (left, right)
|
|
|
45
44
|
export const Modulo = (source, block) => arithmetic(source, block, (left, right) => left.modulo(right));
|
|
46
45
|
export const Power = (source, block) => arithmetic(source, block, (left, right) => left.power(right));
|
|
47
46
|
export const Equals = (source, block) => {
|
|
48
|
-
return source.equals(block);
|
|
47
|
+
return failure(source) ?? failure(block) ?? source.equals(block);
|
|
49
48
|
};
|
|
50
49
|
/** `==`: the same value and the same type at every node. */
|
|
51
50
|
export const TypeEquals = (source, block) => {
|
|
52
|
-
return source.typeEquals(block);
|
|
51
|
+
return failure(source) ?? failure(block) ?? source.typeEquals(block);
|
|
53
52
|
};
|
|
54
53
|
/** `===`: the same frame. Atoms, which own no identity, fall back to `==`. */
|
|
55
54
|
export const Identical = (source, block) => {
|
|
56
|
-
return source.identical(block);
|
|
55
|
+
return failure(source) ?? failure(block) ?? source.identical(block);
|
|
57
56
|
};
|
|
58
|
-
export const GreaterThan = (source, block) =>
|
|
59
|
-
export const GreaterThanOrEqual = (source, block) =>
|
|
60
|
-
export const LessThan = (source, block) =>
|
|
61
|
-
export const LessThanOrEqual = (source, block) =>
|
|
57
|
+
export const GreaterThan = (source, block) => arithmetic(source, block, (left, right) => left.greaterThan(right));
|
|
58
|
+
export const GreaterThanOrEqual = (source, block) => arithmetic(source, block, (left, right) => left.greaterThanOrEqual(right));
|
|
59
|
+
export const LessThan = (source, block) => arithmetic(source, block, (left, right) => left.lessThan(right));
|
|
60
|
+
export const LessThanOrEqual = (source, block) => arithmetic(source, block, (left, right) => left.lessThanOrEqual(right));
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.39.0";
|