~ chicken-core (chicken-5) 8b5687703fb8f4de85cd9a6116f4d7459e639710
commit 8b5687703fb8f4de85cd9a6116f4d7459e639710
Author: Pietro Cerutti <gahr@gahr.ch>
AuthorDate: Thu Sep 21 12:10:45 2023 +0000
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Tue Sep 26 13:40:29 2023 +0200
Disallow empty "or" type specifier
This fixes an inconsistency in the `or` type specifier when used with an empty argument list, whereas, contrary to how the `(or)` function is `#f`, the `(or)` type specifier is `*`.
Signed-off-by: felix <felix@call-with-current-continuation.org>
diff --git a/manual/Types b/manual/Types
index f3fb6b7b..27ef0fc6 100644
--- a/manual/Types
+++ b/manual/Types
@@ -99,7 +99,7 @@ or {{:}} should follow the syntax given below:
<table>
<tr><th>VALUETYPE</th><th>meaning</th></tr>
-<tr><td>{{(or VALUETYPE ...)}}</td><td>"union" or "sum" type</td></tr>
+<tr><td>{{(or VALUETYPE1 VALUETYPE2 ...)}}</td><td>"union" or "sum" type</td></tr>
<tr><td>{{(not VALUETYPE)}}</td><td>non-matching type (*)</td></tr>
<tr><td>{{(struct STRUCTURENAME)}}</td><td>record structure of given kind</td></tr>
<tr><td>{{(procedure [NAME] (VALUETYPE ... [#!optional VALUETYPE ...] [#!rest [VALUETYPE]]) . RESULTS)}}</td><td>procedure type, optionally with name</td></tr>
@@ -241,7 +241,7 @@ Procedure types are assumed to be not referentially transparent and
are assumed to possibly modify locally held state. Using the
{{(... --> ...)}} syntax, you can declare a procedure to not modify
local state, i.e. not causing any side-effects on local variables or
-data contain in local variables. This gives more opportunities for
+data contained in local variables. This gives more opportunities for
optimization but may not be violated or the results are undefined.
diff --git a/scrutinizer.scm b/scrutinizer.scm
index cdf6f205..35f889e2 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -75,7 +75,7 @@
; result specifiers:
;
; SPEC = * | (TYPE1 ...)
-; TYPE = (or TYPE1 ...)
+; TYPE = (or TYPE1 TYPE2 ...)
; | (not TYPE)
; | (struct NAME)
; | (procedure [NAME] (TYPE1 ... [#!optional TYPE1 ...] [#!rest [TYPE | values]]) . RESULTS)
@@ -1911,6 +1911,7 @@
v))
((eq? 'or (car t))
(and (list? t)
+ (not (null? (cdr t)))
(let ((ts (map validate (cdr t))))
(and (every identity ts)
`(or ,@ts)))))
Trap