Skip to content
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

Using "void"-functions as arguments leads to "Illegal expression type" #70

Closed
GWRon opened this issue Jan 23, 2015 · 5 comments
Closed
Assignees
Labels

Comments

@GWRon
Copy link
Contributor

GWRon commented Jan 23, 2015

SuperStrict
Framework Brl.StandardIO

'no return value!
Function a(i:Int)
End Function

Function b:Int()
    Return a(1) - a(2)
End Function

b()

Fails with "Illegal expression type" on the Return a(1) - a(2)_ call. On Vanilla it compiles and would return "0".

@woollybah
Copy link
Member

I'd say this is a valid error. Perhaps the error message should be more explicit, but I think it should fail, regardless of what legacy bcc does.

@GWRon
Copy link
Contributor Author

GWRon commented Jan 23, 2015

If course I think NG is allowed to error on more things - as long as it explains why it is failing. Do not misunderstand me: I know that the issues are errors in my code :p

@GWRon
Copy link
Contributor Author

GWRon commented Jan 23, 2015

While "return a(1)" is a valid error - shouldnt a subtraction of "void" result in something like 0?

No ... I am not "joking" (albeit I started this comment to write something not that serious)

The function b:int() returns an integer value. When doing the math operation of "void - void" you should end up with "0", same for "void/void" = "1". I mean, these are rare special cases and really constructed ... but maybe there are more cases of "math(void)" returning real mathematic values.

I still understand, that the above is something really "constructed" and no real-world-scenario.

@woollybah
Copy link
Member

If you are using Strict, then you can do what you like.
However, I think SuperStrict should at least try to be super-strict, otherwise we may want to rename it to something like "MostlySuperStrict" :-)

In legacy BlitzMax, all functions return at least Int, regardless of strictness. C doesn't let you mix and match, and it turns out that emscripten really doesn't like you doing "fun" things with inappropriately mixed function signatures. (You may consider emscripten to be ReallySuperStrict)

On 23 Jan 2015, at 16:09, Ronny Otto notifications@github.com wrote:

While "return a(1)" is a valid error - shouldnt a subtraction of "void" result in something like 0?

No ... I am not "joking" (albeit I started this comment to write something not that serious)

The function b:int() returns an integer value. When doing the math operation of "void - void" you should end up with "0", same for "void/void" = "1". I mean, these are rare special cases and really constructed ... but maybe there are more cases of "math(void)" returning real mathematic values.

I still understand, that the above is something really "constructed" and no real-world-scenario.


Reply to this email directly or view it on GitHub.

@GWRon
Copy link
Contributor Author

GWRon commented Jan 23, 2015

Like said: I am totally open for just not allowing void as result for something different ... stay tuned for next issues :p

You may close this issue when introducing an error-message ("invalid return type").

@woollybah woollybah added the bug label Jan 26, 2015
@woollybah woollybah self-assigned this Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants