On Fri, 5 Nov 2010, Sven Schreiber wrote:
I stumbled across a glitch with error messages occurring in
nested functions. I'm reporting it not per se, but because it
might hint at a deeper issue with nested functions, given a
history of subtle flakiness with function scopes and such -- I
just don't know [...]
Agreed, the error message(s) you reported are somewhat confusing.
However, I don't think they "hint at a deeper issue" -- it's just
that getting the error reporting "right" is quite tricky. I've now
had another go at this, and I think the output should be clearer.
Here's a simple example:
<script>
function scalar f3 (scalar x)
y = sqrt(z) # deliberate error here
return y
end function
function scalar f2 (scalar x)
return f3(x)
end function
function scalar f1 (scalar x)
return f2(x)
end function
# main
scalar s = f1(9)
</script>
The output from the above is now:
<output>
? scalar s = f1(9)
The symbol 'z' is undefined
*** error in function f3
y = sqrt(z)
called by function f2
called by function f1
</output>
That is, we print only one "error in function" message, pertaining
to the function which directly produced the error, and if this
function is nested we follow up by printing the "call stack".
Allin