-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluating function's return value within it causes program to crash. #549
Comments
This is working as designed. The function PRINT f
FUNCTION f ()
PRINT "Entered f()"
_DELAY 0.1!
f = f + 1
END FUNCTION |
Oh... now I see. Thanks! I remember (incorrectly?) using Visual Basic for Applications and being able to reference the implicitly defined local variable that holds the return value of the function like any other variable, without this recursive calling behavior, since the references didn't have the function call operator "()". Unfortunately this behavior, even if implemented, wouldn't be totally compatible with the current syntax/semantics (but it's not so far off). Considering the given example, in QB64, if we define F taking any argument, the compiler complains about the wrong number of arguments being passed to the function, when not using the call operator. Indeed that's is consistent with the designed behavior, as you said. Shouldn't, however, the program pop up a dialog box telling the stack has overflown, instead of failing silently? |
I have not used VBA, but I have worked with legacy Visual Basic (which I guess is similar in many ways). However, it's been a long time since I last used VB, so I don't recall if it allowed referencing a function's return value as a variable in the way you're describing.
That's a good point. It would certainly be more helpful if the program alerted the user about a stack overflow, rather than failing silently. |
Describe the bug
If the local variable that has the current function's name (and its current return value) is used in an expression the program immediately crashes.
To Reproduce
Run the following program:
Expected behavior
Although this was not allowed in QBasic/QuickBasic, later versions of Microsoft Basic implement this feature. Ideally, I think its use should be allowed, because it's useful and probably won't introduce any compatibility issues. Otherwise, it should just cause a compilation time error.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: