* module/language/tree-il/analyze.scm (proc-ref?): Check for
SPECIAL-NAME in the <module-ref> and <lexical-ref> cases too.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string using gettext as module-ref _", "non-literal format
string using gettext as lexical _"): New tests.
(($ <module-ref> _ module name public?)
(let* ((mod (if public?
(false-if-exception (resolve-interface module))
- (resolve-module module #:ensure? #f)))
+ (resolve-module module #:ensure #f)))
(var (and mod (module-variable mod name))))
- (and var (variable-bound? var) (eq? (variable-ref var) proc))))
+ (if var
+ (and (variable-bound? var) (eq? (variable-ref var) proc))
+ (eq? name special-name))))
+ (($ <lexical-ref> _ (? (cut eq? <> special-name)))
+ #t)
(_ #f)))
(define gettext? (cut proc-ref? <> gettext '_ <>))
#:opts %opts-w-format
#:to 'assembly)))))
+ (pass-if "non-literal format string using gettext as module-ref _"
+ (null? (call-with-warnings
+ (lambda ()
+ (compile '(format #t ((@@ (foo) _) "~A ~A!") "hello" "world")
+ #:opts %opts-w-format
+ #:to 'assembly)))))
+
+ (pass-if "non-literal format string using gettext as lexical _"
+ (null? (call-with-warnings
+ (lambda ()
+ (compile '(let ((_ (lambda (s)
+ (gettext s "my-domain"))))
+ (format #t (_ "~A ~A!") "hello" "world"))
+ #:opts %opts-w-format
+ #:to 'assembly)))))
+
(pass-if "non-literal format string using ngettext"
(null? (call-with-warnings
(lambda ()