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

disallow ccall and cglobal as variable names #26537

Merged
merged 1 commit into from
Mar 23, 2018
Merged

Conversation

JeffBezanson
Copy link
Member

These used to be normal identifiers but over time have become quasi-syntax. As a result you get behavior like this:

julia> ccall(x) = x
ccall (generic function with 1 method)

julia> ccall(2)
ERROR: syntax: too few arguments to ccall

This change prevents that from happening by disallowing assigning to or otherwise creating a variable with these names.

also add an error check for `global true`
@JeffBezanson JeffBezanson added breaking This change will break code compiler:lowering Syntax lowering (compiler front end, 2nd stage) labels Mar 20, 2018
@vtjnash
Copy link
Member

vtjnash commented Mar 20, 2018

Makes sense for ccall, since I think we're going to keep the current behavior (due to the shear inertia of the existing code). For cglobal, it's not clear to my why we should be treating this as special syntax. I'm pretty sure we can easily either make this a perfectly normal function, or make it a perfectly normal macro – I think we just need to decide what semantics it's suppose to guarantee (is it syntax or optimization?).

@JeffBezanson
Copy link
Member Author

There are some cases where we treat cglobal specially, e.g. #26504 and linearization. If it's possible to reliably optimize for constant arguments even when it's a normal function, then that would be ideal. Making it a macro would be ok if that's not possible.

@JeffBezanson JeffBezanson merged commit 78c7d87 into master Mar 23, 2018
@JeffBezanson JeffBezanson deleted the jb/ccallcglobal branch March 23, 2018 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants