diff options
author | Andy Wingo <wingo@pobox.com> | 2021-01-07 10:15:32 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2021-01-07 10:26:33 +0100 |
commit | 9d5978a756008b536fbb13e6de67ae0b4741b161 (patch) | |
tree | e658ccc1991cc8745eee59b0a1ecb1b7e1793a8a /module/system/base | |
parent | 64c89458e6b4fcc834ed86bf0d6606a5a1044e7e (diff) | |
download | guile-9d5978a756008b536fbb13e6de67ae0b4741b161.tar.gz |
New warnings: -Wuse-before-definition, -Wnon-idempotent-definition
* module/ice-9/boot-9.scm (%auto-compilation-options): Add
use-before-definition and non-idempotent-definition.
* module/language/tree-il/analyze.scm (<use-before-def-info>): New
analysis info.
(make-use-before-definition-analysis): New function.
(goops-toplevel-definition): Move down.
(unbound-variable-analysis, macro-use-before-definition): Remove, as
they are subsumed by use-before-def. There are some deprecated
bindings though.
(make-analyzer): Rework to allow for use-before-def analysis to handle
multiple
* module/system/base/message.scm (%warning-types): Add handlers for the
new warning types.
* test-suite/tests/tree-il.test: Add tests.
* doc/ref/api-evaluation.texi (Compilation): Update.
Diffstat (limited to 'module/system/base')
-rw-r--r-- | module/system/base/message.scm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/module/system/base/message.scm b/module/system/base/message.scm index 21d06cc88..3cd862bd4 100644 --- a/module/system/base/message.scm +++ b/module/system/base/message.scm @@ -1,6 +1,6 @@ ;;; User interface messages -;; Copyright (C) 2009-2012,2016,2018,2020 Free Software Foundation, Inc. +;; Copyright (C) 2009-2012,2016,2018,2020-2021 Free Software Foundation, Inc. ;;; This library is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU Lesser General Public License as published by @@ -127,6 +127,18 @@ (emit port "~A: warning: macro `~A' used before definition~%" loc name))) + (use-before-definition + "report uses of top-levels before they are defined" + ,(lambda (port loc name) + (emit port "~A: warning: `~A' used before definition~%" + loc name))) + + (non-idempotent-definition + "report names that can refer to imports on first load, but module definitions on second load" + ,(lambda (port loc name) + (emit port "~A: warning: non-idempotent binding for `~A'. When first loaded, value for `~A` comes from imported binding, but later module-local definition overrides it; any module reload would capture module-local binding rather than import.~%" + loc name name))) + (arity-mismatch "report procedure arity mismatches (wrong number of arguments)" ,(lambda (port loc name certain?) |