Skip to content

Commit

Permalink
FIX: WRITE should use MOLD instead of FORM when writing an object int…
Browse files Browse the repository at this point in the history
…o a file

fixes: #16
related to: Oldes/Rebol-issues#2007
  • Loading branch information
Oldes committed May 26, 2020
1 parent 6d083e4 commit 3360dac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/p-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ REBINT Mode_Syms[] = {
args = Find_Refines(ds, ALL_WRITE_REFS);
spec = D_ARG(2); // data (binary, string, or block)

if (!(IS_BINARY(spec) || IS_STRING(spec) || IS_BLOCK(spec))) {
if (!(IS_BINARY(spec) || IS_STRING(spec))) {
//Trap1(RE_INVALID_ARG, spec);
REB_MOLD mo = {0};
Reset_Mold(&mo);
Mold_Value(&mo, spec, 0);
Mold_Value(&mo, spec, TRUE);
Set_String(spec, mo.series);
}

Expand Down
6 changes: 6 additions & 0 deletions src/tests/units/port-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ Rebol [
--assert "test" = read/string write %foo "test"
delete %foo

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

===end-group===

Expand Down

0 comments on commit 3360dac

Please sign in to comment.