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

incorrect determination of macro # of arguments #16594

Closed
StephenVavasis opened this issue May 26, 2016 · 6 comments
Closed

incorrect determination of macro # of arguments #16594

StephenVavasis opened this issue May 26, 2016 · 6 comments
Labels
parser Language parsing and surface syntax

Comments

@StephenVavasis
Copy link
Contributor

The macro invocation below fails with an error "wrong number of arguments". Notice that the expression is spread over two lines. Somehow the loader is seeing the text after @einsum as two (or more?) arguments to the einsum macro instead of just one. This is version 0.4.5 (downloaded today)

The problem goes away if I concatenate the two lines into one. Even more oddly, the problem goes away if I simply insert a space character after the plus sign that terminates the first line!

This problem is not special for the einsum macro; the same thing happens for other macros I tried.

        @einsum ws.d_deltas[ind1,ind2,ind3,ind4] = ws.d_deltas_t1[ind1,ind2,ind3,ind4] +
         ws.d_deltas_t2[ind1,ind2,ind3,ind4] # (s,I,j,k)
@ivarne ivarne added the parser Language parsing and surface syntax label May 26, 2016
@ivarne
Copy link
Member

ivarne commented May 26, 2016

Does this work in other versions (eg. do you know/think that it previously worked)?

@kmsquire
Copy link
Member

Even if it worked previously, making it work by adding a space at the end of a line seems pretty fragile.

@StephenVavasis
Copy link
Contributor Author

With regard to the versions: I noticed the problem in 0.4.2, and then I downloaded 0.4.5 yesterday to see if it has been fixed. (It hasn't been.)

@vtjnash
Copy link
Member

vtjnash commented Jun 13, 2016

simpler testcase:

julia> macro einsum(args...)
         println(args)
         return length(args)
       end

julia> @einsum a = b +
(:(a = b),:+)
2

@TotalVerb
Copy link
Contributor

Similar situation:

julia> [1 +
       2 0]
2×2 Array{Any,2}:
 1   +
 2  0 

julia> [1 + 
       2 0]
1×2 Array{Int64,2}:
 3  0

The only difference is that there is a trailing whitespace in the second example.

@stevengj
Copy link
Member

As mentioned in #20258, this seems to occur only for operators like + that are both binary and unary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

6 participants