Skip to content

Commit 3360dac

Browse files
committed
FIX: WRITE should use MOLD instead of FORM when writing an object into a file
fixes: #16 related to: Oldes/Rebol-issues#2007
1 parent 6d083e4 commit 3360dac

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/core/p-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ REBINT Mode_Syms[] = {
451451
args = Find_Refines(ds, ALL_WRITE_REFS);
452452
spec = D_ARG(2); // data (binary, string, or block)
453453

454-
if (!(IS_BINARY(spec) || IS_STRING(spec) || IS_BLOCK(spec))) {
454+
if (!(IS_BINARY(spec) || IS_STRING(spec))) {
455455
//Trap1(RE_INVALID_ARG, spec);
456456
REB_MOLD mo = {0};
457457
Reset_Mold(&mo);
458-
Mold_Value(&mo, spec, 0);
458+
Mold_Value(&mo, spec, TRUE);
459459
Set_String(spec, mo.series);
460460
}
461461

src/tests/units/port-test.r3

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ Rebol [
8484
--assert "test" = read/string write %foo "test"
8585
delete %foo
8686

87+
--test-- "write non binary data to file"
88+
;@@ https://github.com/Oldes/Rebol3/issues/16
89+
--assert "make object! [^/ type: 'foo^/]" = read/string write %foo object [type: 'foo]
90+
--assert "[a: 1]" = read/string write %foo [a: 1]
91+
--assert "<foo>" = read/string write %foo <foo>
92+
delete %foo
8793

8894
===end-group===
8995

0 commit comments

Comments
 (0)