mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
Have `-Warity-mismatch' handle applicable structs.
* module/language/tree-il/analyze.scm (arity-analysis): Honor applicable structs. * test-suite/tests/tree-il.test ("warnings")["arity mismatch"]("top-level applicable struct", "top-level applicable struct with wrong arguments"): New tests.
This commit is contained in:
parent
4c98474782
commit
2c5f0bdb0e
2 changed files with 29 additions and 2 deletions
|
@ -1194,8 +1194,15 @@ accurate information is missing from a given `tree-il' element."
|
||||||
(false-if-exception
|
(false-if-exception
|
||||||
(module-ref env name))))
|
(module-ref env name))))
|
||||||
proc)))
|
proc)))
|
||||||
(if (or (lambda? proc*) (procedure? proc*))
|
(cond ((lambda? proc*)
|
||||||
(validate-arity proc* application (lambda? proc*)))))
|
(validate-arity proc* application #t))
|
||||||
|
((struct? proc*)
|
||||||
|
;; An applicable struct.
|
||||||
|
(let ((p (struct-ref proc* 0)))
|
||||||
|
(and (procedure? p)
|
||||||
|
(validate-arity p application #f))))
|
||||||
|
((procedure? proc*)
|
||||||
|
(validate-arity proc* application #f)))))
|
||||||
toplevel-calls)))
|
toplevel-calls)))
|
||||||
|
|
||||||
(make-arity-info vlist-null vlist-null vlist-null)))
|
(make-arity-info vlist-null vlist-null vlist-null)))
|
||||||
|
|
|
@ -1103,6 +1103,26 @@
|
||||||
w "wrong number of arguments to"))))
|
w "wrong number of arguments to"))))
|
||||||
w)))))
|
w)))))
|
||||||
|
|
||||||
|
(pass-if "top-level applicable struct"
|
||||||
|
(null? (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '(let ((p current-warning-port))
|
||||||
|
(p (+ (p) 1))
|
||||||
|
(p))
|
||||||
|
#:opts %opts-w-arity
|
||||||
|
#:to 'assembly)))))
|
||||||
|
|
||||||
|
(pass-if "top-level applicable struct with wrong arguments"
|
||||||
|
(let ((w (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '(let ((p current-warning-port))
|
||||||
|
(p 1 2 3))
|
||||||
|
#:opts %opts-w-arity
|
||||||
|
#:to 'assembly)))))
|
||||||
|
(and (= (length w) 1)
|
||||||
|
(number? (string-contains (car w)
|
||||||
|
"wrong number of arguments to")))))
|
||||||
|
|
||||||
(pass-if "local toplevel-defines"
|
(pass-if "local toplevel-defines"
|
||||||
(let ((w (call-with-warnings
|
(let ((w (call-with-warnings
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue