Skip to content

Commit 6649047

Browse files
committed
FIX: loading unnamed modules was causing failing test
related: Oldes/Rebol-issues#662
1 parent f2fef8f commit 6649047

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

src/mezz/sys-load.reb

+24-7
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,31 @@ load-module: function [
504504
'else [cause-error 'access 'no-script source] ; needs better error
505505
]
506506
]
507-
module? source [ ; see if the same module is already in the list
507+
module? source [
508508
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]
515532
]
516533
]
517534
]

src/tests/units/evaluation-test.r3

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ Rebol [
6262

6363
--test-- "issue-662"
6464
;@@ 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}"]
6767

6868
--test-- "issue-121"
6969
;@@ https://github.com/Oldes/Rebol-issues/issues/121

0 commit comments

Comments
 (0)