commit d33c27b

shrub  ·  2026-10-14 20:21:08 +0000 UTC
parent 9d04fa7
prove there is atleast one output in each build rule
1 files changed,  +13, -4
+13, -4
 1@@ -129,16 +129,25 @@ in
 2 end
 3 
 4 (* collect the outputs of a build stmt assuming the scanner already 
 5- * consumed 'build' *)
 6-fun outputs (s: &scanner, collected: List0_vt(Strptr1)): List0_vt(Strptr1) =
 7+ * consumed 'build' 
 8+ *
 9+ * The 'collected' list is list0 because it starts empty. the  returned
10+ * list is list1 because it must contain atleast one thing. in ATS, list0 
11+ * is allowed to be empty, but list1 isnt. *)
12+fun outputs (s: &scanner, collected: List0_vt(Strptr1)): List1_vt(Strptr1) =
13 let 
14      val () = skipspace(s)
15 in 
16     if (s.cur < 0) || (s.cur = char2int0('\n')) then (
17         paths_free(collected);
18         $raise ParseErr 
19-    ) else if (s.cur = char2int0(':')) then
20-        list_vt_reverse(collected)
21+    ) else if (s.cur = char2int0(':')) then (
22+        if list_vt_length(collected) > 0 then // we need to do this check so that the compiler knows that we
23+            list_vt_reverse(collected)        // are satisfying List1_vt (atleast one thing in the list)
24+        else (
25+            paths_free(collected);
26+            prerrln!("expected at least one output");
27+            $raise ParseErr() ) )
28     else
29         let
30              val path = scanpath(s)