Skip to content

Commit ed9b931

Browse files
committed
Move load-any no load error into cmdModuleLoad
Refactor module procedure to move the error raise when no error and no module loaded in case of a load-any sub-command. This code is moved directly at the end of cmdModuleLoad.
1 parent 6221191 commit ed9b931

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tcl/main.tcl.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,6 @@ proc module {command args} {
497497
# within sourced file evaluation as top load command
498498
if {[isTopEvaluation]} {
499499
set ret [cmdModuleLoad load 1 $tag_list {*}$args]
500-
# raise error if no module has been loaded or has produced an
501-
# error during its load attempt
502-
if {!$ret && $command eq {load-any} && ![is-loaded {*}$args]\
503-
&& ![is-loading {*}$args]} {
504-
knerror "No module has been loaded"
505-
}
506500
} elseif {$mode eq {load}} {
507501
# load here if try-load or no auto mode (done through prereq
508502
# elsewhere, inhibited if currently in DepRe context)

tcl/subcmd.tcl.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,13 @@ proc cmdModuleLoad {context uasked tag_list args} {
826826
reportDebug "loading $args (context=$context, uasked=$uasked)"
827827

828828
set ret 0
829+
set loadok 0
829830
lappendState mode load
830831
foreach mod $args {
831832
# stop when first module in list is loaded if processing load-any cmd
832-
if {[info exists loadok] && $loadok && [currentState any_modulefile]} {
833+
if {$loadok && [currentState any_modulefile]} {
833834
break
834835
}
835-
set loadok 0
836836

837837
# if a switch action is ongoing...
838838
if {$context eq {swload}} {
@@ -1166,6 +1166,13 @@ proc cmdModuleLoad {context uasked tag_list args} {
11661166
}
11671167
lpopState mode
11681168

1169+
# raise error if no module has been loaded or has produced an error during
1170+
# its load attempt in case of load-any sub-command
1171+
if {!$ret && !$loadok && $context eq {load} && [currentState\
1172+
any_modulefile]} {
1173+
knerror "No module has been loaded"
1174+
}
1175+
11691176
return $ret
11701177
}
11711178

0 commit comments

Comments
 (0)