tweaks to -Wformat's gettext detection

* module/language/tree-il/analyze.scm (proc-ref?): Change to use less
  false-if-exception and more variable-bound?.  If a variable is present
  in the local module but not bound, assume that it is gettext if it has
  the right name.  This is to allow for (define _ gettext).

* test-suite/tests/tree-il.test ("warnings"): Update (_ "foo") example.
This commit is contained in:
Andy Wingo 2012-03-02 17:46:28 +01:00
commit dab48cc567
2 changed files with 18 additions and 21 deletions

View file

@ -1352,16 +1352,16 @@ accurate information is missing from a given `tree-il' element."
resort, return #t when EXP refers to the global variable SPECIAL-NAME."
(match exp
(($ <toplevel-ref> _ name)
(let ((var (false-if-exception (module-variable env name))))
(if var
(eq? (false-if-exception (variable-ref var)) ; VAR may be unbound
proc)
(eq? name special-name)))) ; special hack to support local aliases
(let ((var (module-variable env name)))
(if (and var (variable-bound? var))
(eq? (variable-ref var) proc)
(eq? name special-name)))) ; special hack to support local aliases
(($ <module-ref> _ module name public?)
(let ((m (false-if-exception (if public?
(resolve-interface module)
(resolve-module module)))))
(and m (eq? (false-if-exception (module-ref module name)) proc))))
(let* ((mod (if public?
(false-if-exception (resolve-interface module))
(resolve-module module #:ensure? #f)))
(var (and mod (module-variable mod name))))
(and var (variable-bound? var) (eq? (variable-ref var) proc))))
(_ #f)))
(define gettext? (cut proc-ref? <> gettext '_ <>))