REBOL3 tracker
  0.9.12 beta
Ticket #0002151 User: anonymous

Project:

Previous Next
rss
TypeBug Statusdismissed Date10-Jun-2014 11:14
Versionr3 master CategoryParse Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Difference in parse end detection using print vs. function wrapping print
Description I probably haven't reduced this down as much as I could, but this looks like a bug. The only difference is calling PRINT directly vs. a function that calls print...
Example code
;-- working case input

parse ["hello"] [
    any [
        pos: (print do/next pos 'pos) :pos
        (print tail? pos)
    ]
]

;-- working case output

hello
true

true
== true

;-- non-working case input

foo: function [value [any-type!]] [
    print value
]

parse ["hello"] [
    any [
        pos: (foo do/next pos 'pos) :pos
        (print tail? pos)
    ]
]

;-- non-working case output

    hello
true
*** ERROR
** Script error: value has no value
** Where: foo parse
** Near: foo do/next pos 'pos

Assigned ton/a Fixed in- Last Update22-Jun-2014 00:56


Comments
(0004454)
BrianH
22-Jun-2014 00:56

The problem is that for the second round of the any loop, pos is at the end of the input block, and DO/next of an empty block returns an unset! value. When that value is passed to your foo function, it is evaluated in the print value statement. If you don't want that error for an unset! value, use print :value.

Date User Field Action Change
22-Jun-2014 00:56 BrianH Comment : 0004454 Added -
22-Jun-2014 00:53 BrianH Code Modified -
22-Jun-2014 00:53 BrianH Status Modified submitted => dismissed
10-Jun-2014 11:14 fork Ticket Added -