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

inferred macro has trouble with broadcasted operators? #20620

Closed
andyferris opened this issue Feb 16, 2017 · 4 comments · Fixed by #35522
Closed

inferred macro has trouble with broadcasted operators? #20620

andyferris opened this issue Feb 16, 2017 · 4 comments · Fixed by #35522

Comments

@andyferris
Copy link
Member

andyferris commented Feb 16, 2017

I came across this behavior in my StaticArrays tests:

julia> v = [1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> .-v
3-element Array{Int64,1}:
 -1
 -2
 -3

julia> @inferred(.-v)
ERROR: AssertionError: ($(Expr(:globalref, Base.Test, :(==))))(($(Expr(:globalref, Base.Test, :length)))(#46#inftypes), 1)

julia> b = [true,false]
2-element Array{Bool,1}:
  true
 false

julia> .!b
2-element BitArray{1}:
 false
  true

julia> @inferred(.!b)
ERROR: UndefVarError: .! not defined
@TotalVerb
Copy link
Contributor

TotalVerb commented Feb 17, 2017

This is not specific to unary operators. @inferred does not understand dot notation at all. It only appears to work for binary operators because (some) binary operators can be used as function objects.

Note

julia> @inferred(foo.(true, false))
ERROR: @inferred requires a call expression

and

julia> const  = +
+ (generic function with 180 methods)

julia> @inferred(1 .⊕ 2)
ERROR: UndefVarError: .⊕ not defined

@StefanKarpinski StefanKarpinski changed the title inferred macro has trouble with broadcasted unary operators? inferred macro has trouble with broadcasted operators? Feb 17, 2017
@andreasnoack
Copy link
Member

@stevengj Do you have an idea how to handle dot expressions in inferred?

@TotalVerb
Copy link
Contributor

An easy way to do it would be to expand the expression first, though I don't know if this is robust.

@andreasnoack
Copy link
Member

Had the same idea before posting here but expanded dot expressions are not so simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants