File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -339,8 +339,17 @@ static int Check_Char_Range(REBVAL *val, REBINT limit)
339
339
340
340
if (!HAS_FRAME (word )) return R_NONE ;
341
341
if (VAL_WORD_INDEX (word ) < 0 ) {
342
- // was originally returning R_TRUE for function context
343
- * D_RET = Stack_Frame (1 )[3 ];
342
+ // was originally returning R_TRUE for all function contexts
343
+ // we can try to resolve the function from stack (VAL_WORD_FRAME is not valid in this case)
344
+ REBVAL * frame = Stack_Frame (1 );
345
+ // if there was no frame on the stack, the word is a leaked local of some function
346
+ // and it looks there is no way how to resolve it, so return NONE
347
+ if (!frame )
348
+ // this is in case like ` f: func[a][p: 'a] f 1 context? p `
349
+ return R_NONE ;
350
+ // else return function spec
351
+ // case like: ` f: func[a][context? 'a] f 1 `
352
+ * D_RET = frame [3 ];
344
353
} else {
345
354
SET_OBJECT (D_RET , VAL_WORD_FRAME (word ));
346
355
}
Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ Rebol [
78
78
f2 arg1
79
79
]
80
80
--assert [a] = f 1 2
81
+
82
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/886
83
+ f : func [ arg] [p: 'arg]
84
+ f 1 2
85
+ --assert none? context? p ; and no crash!
86
+
87
+ c: closure[a][context? 'a]
88
+ --assert all [object? o: c 1 o/a = 1 ]
81
89
===end-group===
82
90
83
91
You can’t perform that action at this time.
0 commit comments