REBOL3 tracker
  0.9.12 beta
Ticket #0000885 User: anonymous

Project:



rss
TypeBug Statusreviewed Date3-Jun-2009 20:01
Versionalpha 55 CategoryNative Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary Explicit DO of a function makes STACK /func or /args of that function call not work
Description If you call a function directly or use APPLY, STACK/func works. If you DO the function value, it returns unset!. STACK/args returns an empty list for that call.
Example code
; STACK/func test
>> f: func [a] [type? stack/func 1]
== make function! [[a][type? stack/func 1]]
>> f 1
== function!
>> apply :f [1]
== function!
>> do :f 1
== unset!  ; should be function!

; STACK/args test
>> f: func [a] [stack/args 1]
== make function! [[a][stack/args 1]]
>> f 1
== [1]
>> apply :f [1]
== [1]
>> do :f 1
== []  ; should be [1]

; STACK/block test
>> f: func [a] [stack/block 1]
== make function! [[a][stack/block 1]]
>> f 1
== [f 1]
>> apply :f [1]
== [1]
>> do :f 1
== [:f 1]

Assigned ton/a Fixed in- Last Update31-Jan-2011 06:45


Comments
(0002752)
BrianH
2-Nov-2010 06:25

In alpha 108 this bug was partially fixed, but now has new bugs. Here is the new behavior (old behavior left above for reference):

; STACK/func test
>> f: func [a] [type? stack/func 1] f 1
== function!
>> apply func [a] [type? stack/func 1] [1]
== function!
>> do func [a] [type? stack/func 1] 1
** Script error: function! is missing its a argument
** Where: function!
** Near: [type? stack/func 1] 1

; Narrowing it down...
>> do func [a] [print mold try [stack/func 2]] 1
make error! [
code: 304
type: 'Script
id: 'no-arg
arg1: 'function!
arg2: 'a
arg3: none
near: [try [stack/func 2]]
where: [try function!]
]

Clearly STACK/func is DOing the function instead of just returning it if the function was evaluated with DO in the first place, and complaining that it doesn't have an argument. If you actually provide an argument you get weird nonsense data that makes me think that STACK is evaluating some random data in memory. This is arguably worse than before.

; STACK/args test
>> f: func [a] [stack/args 1] f 1
== [1] ; good
>> apply func [a] [stack/args 1] [1]
== [1] ; good
>> do func [a] [stack/args 1] 1
== [1] ; good

; STACK/block test
>> f: func [a] [stack/block 1] f 1
== [f 1] ; good
>> apply func [a] [stack/block 1] [1]
== [1] ; weird
>> apply :f [1]
== [1] ; still weird
>> do func [a] [stack/block 1] 1
== [[stack/block 1] 1] ; REALLY weird
>> do :f 1
== [:f 1] ; maybe weird

So STACK still has some work needed.

Date User Field Action Change
31-Jan-2011 06:45 BrianH Category Modified Unspecified => Native
2-Nov-2010 06:25 BrianH Comment : 0002752 Added -
2-Nov-2010 06:08 BrianH Category Modified => Unspecified
2-Nov-2010 06:08 BrianH Status Modified submitted => reviewed
3-Jun-2009 20:30 BrianH Summary Modified Explicit DO of a function makes STACK/func of that function call return unset! => Explicit DO of a function makes STACK /func or /args of that function call not work
3-Jun-2009 20:30 BrianH Description Modified -
3-Jun-2009 20:30 BrianH Code Modified -
3-Jun-2009 20:01 BrianH Ticket Added -