Skip to content

Conversation

thchr
Copy link
Collaborator

@thchr thchr commented Sep 20, 2022

Some minor nits found with JET.

The point of changes in src/SVector.jl and src/SArray.jl is that the if-statement otherwise cannot know that the call to .head is meaningful (it still thinks that ex.args[1] isa Any). This change just splits it up and type-asserts so the knowledge that ex isa Expr can propagate. The code duplication is a little annoying, but I couldn't think of a good way to avoid it.

Since it's a macro it doesn't really matter - but I figured it might be nice anyway in order to reduce noise in reports by JET in the future.

Copy link
Collaborator

@mateuszbaran mateuszbaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have coverage for these error messages but other than that it looks fine.

@thchr
Copy link
Collaborator Author

thchr commented Sep 23, 2022

Would be happy to add some tests. Only... I don't know how to (if it is possible?) to create a :comprehension whose first argument is not a :generator? I.e., I'm not sure what would actually fail this test. Any ideas?

@mateuszbaran
Copy link
Collaborator

[1 for i in 1:10 for j in 1:10] has :flatten inside :comprehension so it would work as an example:

julia> dump(:([1 for i in 1:10 for j in 1:10]))
Expr
  head: Symbol comprehension
  args: Array{Any}((1,))
    1: Expr
      head: Symbol flatten
      args: Array{Any}((1,))
        1: Expr
          head: Symbol generator
          args: Array{Any}((2,))
            1: Expr
              head: Symbol generator
              args: Array{Any}((2,))
                1: Int64 1
                2: Expr
            2: Expr
              head: Symbol =
              args: Array{Any}((2,))
                1: Symbol i
                2: Expr

@thchr
Copy link
Collaborator Author

thchr commented Sep 24, 2022

Fantastic, thanks - that'll do it! Added tests in ead793e.

@mateuszbaran mateuszbaran merged commit 17e8c37 into JuliaArrays:master Sep 26, 2022
@thchr thchr deleted the jet-1 branch September 29, 2022 11:55
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 this pull request may close these issues.

2 participants