Skip to content

Commit a6809ed

Browse files
Patrick HäckerCopilot
andcommitted
Fix review findings
- Switch to `default` as defined by triage - Use a more vague wording in documentation to indicate that the implementation can evolve in the future - Fix the at least misleading if not incorrect wording in NEWS. Co-authored-by: Copilot <copilot@github.com>
1 parent 5b23344 commit a6809ed

7 files changed

Lines changed: 21 additions & 19 deletions

File tree

NEWS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ Command-line option changes
4141
---------------------------
4242

4343
- `-P <project>` is now a shorthand for `--project <project>` ([#59867]).
44-
- The `--warn-overwrite` option now accepts the new default `auto` in addition to `yes`
45-
and `no`. In this mode, warnings are shown only when a method is overwritten by a
46-
different module, which is the case that errors during precompilation ([#61388]).
44+
- The `--warn-overwrite` option gains a new value `default` (now the default), in addition
45+
to `yes` and `no`. Under `default`, warnings are emitted only for cross-module method
46+
overwrites — typically unintentional cases such as method piracy or package conflicts
47+
([#61388]).
4748

4849
Multi-threading changes
4950
-----------------------

doc/man/julia.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ Load or save history
171171
Enable or disable syntax and method deprecation warnings (`error` turns warnings into errors)
172172

173173
.TP
174-
--warn-overwrite={yes|no|auto*}
175-
Enable or disable method overwrite warnings (`auto` warns for cross-module overwrites only)
174+
--warn-overwrite={yes|no|default*}
175+
Enable or disable method overwrite warnings (`default` warns for likely-unintentional overwrites, currently: cross-module overwrites)
176176

177177
.TP
178178
--warn-scope={yes*|no}

doc/src/manual/command-line-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ The following is a complete list of command-line switches available when launchi
197197
|`--color={yes\|no\|auto*}` |Enable or disable color text|
198198
|`--history-file={yes*\|no}` |Load or save history|
199199
|`--depwarn={yes\|no*\|error}` |Enable or disable syntax and method deprecation warnings (`error` turns warnings into errors)|
200-
|`--warn-overwrite={yes\|no\|auto*}` |Enable or disable method overwrite warnings (`auto` warns for cross-module overwrites only)|
200+
|`--warn-overwrite={yes\|no\|default*}` |Enable or disable method overwrite warnings (`default` warns for likely-unintentional overwrites, currently: cross-module overwrites)|
201201
|`--warn-scope={yes*\|no}` |Enable or disable warning for ambiguous top-level scope|
202202
|`-C`, `--cpu-target <target>` |Limit usage of CPU features up to `<target>`; set to `help` to see the available options|
203203
|`-O`, `--optimize={0\|1\|2*\|3}` |Set the optimization level (level is 3 if `-O` is used without a level) ($)|

src/gf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ static void method_overwrite(jl_typemap_entry_t *newentry, jl_method_t *oldvalue
20592059
dt = jl_nth_argument_datatype(oldvalue->sig, 3);
20602060
int anon = dt && is_anonfn_typename(jl_symbol_name(dt->name->name));
20612061
if ((jl_options.warn_overwrite == JL_OPTIONS_WARN_OVERWRITE_ON) ||
2062-
(jl_options.warn_overwrite == JL_OPTIONS_WARN_OVERWRITE_AUTO && oldmod != newmod) ||
2062+
(jl_options.warn_overwrite == JL_OPTIONS_WARN_OVERWRITE_DEFAULT && oldmod != newmod) ||
20632063
(jl_options.incremental && jl_generating_output()) || anon) {
20642064
JL_STREAM *s = JL_STDERR;
20652065
jl_printf(s, "WARNING: Method definition ");

src/jloptions.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ JL_DLLEXPORT void jl_init_options(void)
124124
#endif
125125
JL_OPTIONS_CHECK_BOUNDS_DEFAULT, // check_bounds
126126
JL_OPTIONS_DEPWARN_OFF, // deprecation warning
127-
JL_OPTIONS_WARN_OVERWRITE_AUTO, // method overwrite warning
127+
JL_OPTIONS_WARN_OVERWRITE_DEFAULT, // method overwrite warning
128128
1, // can_inline
129129
JL_OPTIONS_POLLY_ON, // polly
130130
NULL, // trace_compile
@@ -245,8 +245,9 @@ static const char opts[] =
245245
// error and warning options
246246
" --depwarn={yes|no*|error} Enable or disable syntax and method deprecation\n"
247247
" warnings (`error` turns warnings into errors)\n"
248-
" --warn-overwrite={yes|no|auto*} Enable or disable method overwrite warnings\n"
249-
" (`auto` warns for cross-module overwrites only)\n"
248+
" --warn-overwrite={yes|no|default*} Enable or disable method overwrite warnings\n"
249+
" (`default` warns for likely-unintentional overwrites,\n"
250+
" currently: cross-module overwrites)\n"
250251
" --warn-scope={yes*|no} Enable or disable warning for ambiguous top-level\n"
251252
" scope\n\n"
252253

@@ -929,10 +930,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
929930
jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_ON;
930931
else if (!strcmp(optarg,"no"))
931932
jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_OFF;
932-
else if (!strcmp(optarg,"auto"))
933-
jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_AUTO;
933+
else if (!strcmp(optarg,"default"))
934+
jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_DEFAULT;
934935
else
935-
jl_errorf("julia: invalid argument to --warn-overwrite={yes|no|auto} (%s)", optarg);
936+
jl_errorf("julia: invalid argument to --warn-overwrite={yes|no|default} (%s)", optarg);
936937
break;
937938
case opt_warn_scope:
938939
if (!strcmp(optarg,"yes"))

src/julia.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,7 @@ JL_DLLEXPORT int jl_generating_output(void) JL_NOTSAFEPOINT;
26152615

26162616
#define JL_OPTIONS_WARN_OVERWRITE_OFF 0
26172617
#define JL_OPTIONS_WARN_OVERWRITE_ON 1
2618-
#define JL_OPTIONS_WARN_OVERWRITE_AUTO 2
2618+
#define JL_OPTIONS_WARN_OVERWRITE_DEFAULT 2
26192619

26202620
#define JL_OPTIONS_WARN_SCOPE_OFF 0
26212621
#define JL_OPTIONS_WARN_SCOPE_ON 1

test/misc.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ let
9999
WARNING: Method definition f() in module Main at none:2 overwritten at none:3.
100100
WARNING: Method definition g() in module Main at none:4 overwritten on the same line.
101101
"""
102-
# default (auto): warn on cross-module overwrites and anonymous functions
102+
# default: warn on cross-module overwrites and anonymous functions
103103
warning_str = read(`$exename --startup-file=no -e $script`, String)
104104
@test warning_str == """
105105
WARNING: Method definition f() in module A at none:2 overwritten in module Main on the same line (check for duplicate calls to `include`).
106106
WARNING: Method definition g() in module Main at none:4 overwritten on the same line.
107107
"""
108-
# --warn-overwrite=auto: same as default
109-
warning_str = read(`$exename --warn-overwrite=auto --startup-file=no -e $script`, String)
108+
# --warn-overwrite=default: same as default
109+
warning_str = read(`$exename --warn-overwrite=default --startup-file=no -e $script`, String)
110110
@test warning_str == """
111111
WARNING: Method definition f() in module A at none:2 overwritten in module Main on the same line (check for duplicate calls to `include`).
112112
WARNING: Method definition g() in module Main at none:4 overwritten on the same line.
@@ -116,15 +116,15 @@ let
116116
@test warning_str == """
117117
WARNING: Method definition g() in module Main at none:4 overwritten on the same line.
118118
"""
119-
# same-module overwrite: no warning with auto
119+
# same-module overwrite: no warning with default
120120
same_mod_script = """
121121
$redir_err
122122
f(x) = 5*x
123123
f(x) = 2*x
124124
"""
125125
warning_str = read(`$exename --startup-file=no -e $same_mod_script`, String)
126126
@test warning_str == ""
127-
# cross-module overwrite: warning with auto
127+
# cross-module overwrite: warning with default
128128
cross_mod_script = """
129129
$redir_err
130130
module B; h(x) = 1; end

0 commit comments

Comments
 (0)