mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Avoid failure when `format-analysis' stumbles upon unbound variables.
* module/language/tree-il/analyze.scm (proc-ref?): Wrap `variable-ref' in `false-if-exception'. * test-suite/tests/tree-il.test ("warnings")["format"]("non-literal format string with forward declaration"): New test.
This commit is contained in:
parent
a850c3ccc4
commit
d316047326
2 changed files with 15 additions and 1 deletions
|
@ -1354,7 +1354,8 @@ resort, return #t when EXP refers to the global variable SPECIAL-NAME."
|
|||
(($ <toplevel-ref> _ name)
|
||||
(let ((var (false-if-exception (module-variable env name))))
|
||||
(if var
|
||||
(eq? (variable-ref var) proc)
|
||||
(eq? (false-if-exception (variable-ref var)) ; VAR may be unbound
|
||||
proc)
|
||||
(eq? name special-name)))) ; special hack to support local aliases
|
||||
(($ <module-ref> _ module name public?)
|
||||
(let ((m (false-if-exception (if public?
|
||||
|
|
|
@ -2184,6 +2184,19 @@
|
|||
#:opts %opts-w-format
|
||||
#:to 'assembly)))))
|
||||
|
||||
(pass-if "non-literal format string with forward declaration"
|
||||
(let ((w (call-with-warnings
|
||||
(lambda ()
|
||||
(compile '(begin
|
||||
(define (foo)
|
||||
(format #t (_ "~A ~A!") "hello" "world"))
|
||||
(define _ bar))
|
||||
#:opts %opts-w-format
|
||||
#:to 'assembly)))))
|
||||
(and (= (length w) 1)
|
||||
(number? (string-contains (car w)
|
||||
"non-literal format string")))))
|
||||
|
||||
(pass-if "wrong format string"
|
||||
(let ((w (call-with-warnings
|
||||
(lambda ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue