@@ -47,7 +47,7 @@
48+$ import-diagnostic
48+$ import-diagnostic
49 $% [%ok value=imported]
49 $% [%ok value=imported]
50− [%invalid code=?(%aura %core) message=@t]
50+ [%invalid code=?(%aura %core %overlap) message=@t]
51 [%unsupported message=@t]
51 [%unsupported message=@t]
53+$ signatures (list [name=term code=hoon])
53+$ signatures (list [name=term code=hoon])
@@ -132,6 +132,35 @@
132 =/ rest $(cases t.cases, tags [u.tag tags])
132 =/ rest $(cases t.cases, tags [u.tag tags])
133 ?~ rest ~
133 ?~ rest ~
134 `[[u.tag i.cases] u.rest]
134 `[[u.tag i.cases] u.rest]
137+:: Bound the new $? branch screen independently of the existing $% path.
138+:: Count raw noun nodes across all cases, and cap pairwise tag comparisons.
139+++ bounded-no-spec-unions
145+ ?: ?=([%bckt ^ ^] h) ~
146+ ?: ?=([%bcwt [^ [^ *]]] h) ~
147+ ?: ?=([%bccn [^ [^ *]]] h) ~
148+ =/ left=(unit @ud) $(h -.h)
150+ $(h +.h, fuel u.left)
151+++ tagged-bounded-cases
152+ |= [cases=(list spec) tags=(list @) fuel=@ud left=@ud]
153+ ^- (unit (list tagged-case))
156+ =/ remaining=(unit @ud) (bounded-no-spec-unions i.cases fuel)
158+ =/ tag=(unit @) (tagged-head i.cases)
160+ ?: (lien tags |=(x=@ =(x u.tag))) ~
161+ =/ rest $(cases t.cases, tags [u.tag tags], fuel u.remaining, left (dec left))
163+ `[[u.tag i.cases] u.rest]
136:: Benign source annotations have different typed representations on
165:: Benign source annotations have different typed representations on
137:: Clay and under eval. Inspect the wrapper as a noun, and validate the
166:: Clay and under eval. Inspect the wrapper as a noun, and validate the
@@ -170,11 +199,19 @@
170 ?~ found ~
199 ?~ found ~
171 =/ body=(unit spec) (tagged-default-union u.found 4)
200 =/ body=(unit spec) (tagged-default-union u.found 4)
172 ?~ body ~
201 ?~ body ~
173− ?. ?=([%bccn *] u.body) ~
203+ [%bccn *]
204+ =/ cases=(list spec) p.u.body
207+ (tagged-cases cases ~)
174− =/ cases=(list spec) p.u.body
209+ =/ cases=(list spec) p.u.body
175− ?~ cases ~
210+ ?~ cases ~
176− ?~ t.cases ~
211+ ?~ t.cases ~
177− (tagged-cases cases ~)
212+ (tagged-bounded-cases cases ~ 4.096 128)
179:: Source proof for dependencies of an explicitly tagged union. Only
216:: Source proof for dependencies of an explicitly tagged union. Only
180:: simple local molds, standard collections and distinct term enums are
217:: simple local molds, standard collections and distinct term enums are
@@ -346,6 +383,63 @@
346 ?. ?=([%cell [%atom %tas [~ @]] *] i.ys) ~
383 ?. ?=([%cell [%atom %tas [~ @]] *] i.ys) ~
347 ?. =(tag.i.xs u.value.head.i.ys) ~
384 ?. =(tag.i.xs u.value.head.i.ys) ~
348 $(xs t.xs, ys t.ys)
385 $(xs t.xs, ys t.ys)
388+:: A finite, positive witness for two three-field tagged source cases.
389+:: The final @t fields admit noun zero. Each middle field is either an
390+:: explicit singleton or exactly two explicit singletons. Match noun
391+:: values independently of their aura labels; other shapes are unknown.
392+++ witness-atom-values
395+ ?: ?=([%atom *] node)
398+ ?. ?=([%fork [* [* ~]]] node) ~
399+ ?. &(?=([%atom *] i.cases.node) ?=([%atom *] i.t.cases.node)) ~
400+ ?~ value.i.cases.node ~
401+ ?~ value.i.t.cases.node ~
402+ `~[u.value.i.cases.node u.value.i.t.cases.node]
403+++ witness-tagged-case
405+ ^- (unit [head=@ middle=(list @)])
406+ ?. ?=([%cell [%atom %tas [~ @]] [%cell * [%atom %t ~]]] node) ~
407+ =/ middle (witness-atom-values head.tail.node)
409+ `[u.value.head.node u.middle]
410+++ overlap-zero-source
411+ |= [module=term name=term cor=type]
413+ ?. ?=([%core *] cor) |
414+ =/ selected=(unit hoon) (local-arm-source cor name)
416+ =/ shape=(unit spec) (local-mold-spec u.selected name)
418+ =/ body=(unit spec) (tagged-default-union u.shape 4)
420+ ?. ?=([%bcwt [* [* ~]]] u.body) |
421+ =/ one=spec i.p.u.body
422+ =/ two=spec i.t.p.u.body
423+ =/ first=(unit @) (tagged-head one)
424+ =/ second=(unit @) (tagged-head two)
427+ ?. =(u.first u.second) |
428+ =/ cases=(list tagged-case) ~[[u.first one] [u.second two]]
429+ ?. ?=(^ (safe-source-tagged-fuel-mode cases cor ~[name] 4.096 |)) |
430+ =/ tried=(each (list type) tang)
431+ (mule |.((turn cases |=(c=tagged-case (~(play ut cor) [%kttr branch.c])))))
432+ ?. ?=([%& [* [* ~]]] tried) |
433+ =/ projected=(each (list imported) tang)
434+ (mule |.((turn p.tried |=(t=type (walk module t catalog ~ `cor)))))
435+ ?. ?=([%& [* [* ~]]] projected) |
436+ ?^ (first-bads p.projected) |
437+ =/ a (witness-tagged-case i.p.projected)
438+ =/ b (witness-tagged-case i.t.p.projected)
441+ ?. &(=(head.u.a u.first) =(head.u.b u.second) =(head.u.a head.u.b)) |
442+ (lien middle.u.a |=(n=@ (lien middle.u.b |=(m=@ =(n m)))))
350:: +read-mold-in: accept the /sur core as provenance. The core must be
444:: +read-mold-in: accept the /sur core as provenance. The core must be
351:: built against zuse or validated Ford imports, and its selected arm
445:: built against zuse or validated Ford imports, and its selected arm
@@ -361,6 +455,8 @@
361 [%| (crip "Hoon mold `{(trip name)}` is not declared")]
455 [%| (crip "Hoon mold `{(trip name)}` is not declared")]
362 ?. =(typ (~(play ut cor) (ream (cat 3 '*' name))))
456 ?. =(typ (~(play ut cor) (ream (cat 3 '*' name))))
363 [%| 'Hoon module provenance does not match the selected mold']
457 [%| 'Hoon module provenance does not match the selected mold']
458+ =/ overlap=(each ? tang) (mule |.((overlap-zero-source module name cor)))
459+ ?: &(?=(%& -.overlap) p.overlap) [%| 'Hoon union cases overlap']
364 =/ result (read-with module name typ [~ cor])
460 =/ result (read-with module name typ [~ cor])
365 ?: ?=([%& *] result) result
461 ?: ?=([%& *] result) result
366 =/ fallback=(each (unit (each imported @t)) tang)
462 =/ fallback=(each (unit (each imported @t)) tang)
@@ -461,6 +557,8 @@
461 [%unsupported p.result]
557 [%unsupported p.result]
462 =/ selected=(each type tang) (mule |.((~(play ut cor) (ream (cat 3 '*' name)))))
558 =/ selected=(each type tang) (mule |.((~(play ut cor) (ream (cat 3 '*' name)))))
463 ?. ?=(%& -.selected) [%unsupported p.result]
559 ?. ?=(%& -.selected) [%unsupported p.result]
560+ =/ overlap=(each ? tang) (mule |.((overlap-zero-source module name cor)))
561+ ?: &(?=(%& -.overlap) p.overlap) [%invalid %overlap 'Hoon union cases overlap']
464 =/ again=(each imported tang) (mule |.((walk module p.selected catalog ~ [~ cor])))
562 =/ again=(each imported tang) (mule |.((walk module p.selected catalog ~ [~ cor])))
465 ?. ?=(%& -.again) [%unsupported p.result]
563 ?. ?=(%& -.again) [%unsupported p.result]
466 =/ evidence=(unit import-diagnostic) (first-invalid p.again)
564 =/ evidence=(unit import-diagnostic) (first-invalid p.again)