File tree 2 files changed +26
-9
lines changed
2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -504,14 +504,31 @@ load-module: function [
504
504
'else [cause-error 'access 'no-script source] ; needs better error
505
505
]
506
506
]
507
- module? source [ ; see if the same module is already in the list
507
+ module? source [
508
508
mod: source
509
- foreach [n m] system/modules [
510
- if source = m [
511
- if as [cause-error 'script 'bad-refine /as ] ; already imported
512
- set mod: m
513
- hdr: spec-of mod
514
- return reduce [hdr/name mod]
509
+ hdr: spec-of mod
510
+ ; see if the same module is already in the list
511
+ if all [
512
+ hdr/name
513
+ module? tmp: select system/modules hdr/name
514
+ ][
515
+ if as [cause-error 'script 'bad-refine /as ] ; already imported
516
+ ;; the original code:
517
+ ;; https://github.com/rebol/rebol/blob/25033f897b2bd466068d7663563cd3ff64740b94/src/mezz/sys-load.r#L488-L490
518
+ ;; system/modules was a block with [name module modsum ...]
519
+
520
+ ;; For now I will return existing module when there was not used /version and /check
521
+ ;; but it must be revisited and handled correctly! So far there is not good support
522
+ ;; for modules with same name but different versions:-/
523
+
524
+ ;; Main purpose of this code is to reuse existing module in cases like
525
+ ;; running: `do "rebol [type: module name: n]..."` multiple times
526
+ if all [
527
+ not version
528
+ not check
529
+ equal? mod tmp
530
+ ][
531
+ return reduce [hdr/name tmp]
515
532
]
516
533
]
517
534
]
Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ Rebol [
62
62
63
63
--test-- "issue-662"
64
64
;@@ https://github.com/Oldes/Rebol-issues/issues/662
65
- --assert not error? probe try [do "rebol [type: module] 1 + 1" ]
66
- --assert not error? probe try [do "rebol [type: module] print 'hello " ]
65
+ --assert not error? try [do "rebol [type: module] 1 + 1" ]
66
+ --assert not error? try [do "rebol [type: module] print {Hello issues/662} " ]
67
67
68
68
--test-- "issue-121"
69
69
;@@ https://github.com/Oldes/Rebol-issues/issues/121
You can’t perform that action at this time.
0 commit comments