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

lowering: Disallow splatting in non-final default value #50563

Merged
merged 4 commits into from
Jul 18, 2023

Commits on Jul 15, 2023

  1. lowering: Disallow splatting in non-final default value

    Pop quiz: Do you know what the following will do?
    ```
    julia> function g1(a=(1,2)..., b...=3)
        b
    end
    
    julia> g1()
    
    julia> function g2(a=(1,2)..., b=3, c=4)
        (b, c)
    end
    
    julia> g2()
    
    julia> function g3(a=(1,2)..., b=3, c...=4)
        (b, c)
    end
    
    julia> g3()
    
    julia> g3(1)
    ```
    
    I don't either and I don't think it's particularly well defined.
    Splatting a default argument makes sense on the last argument,
    which can be a vararg, and it is desirable to be able to specify
    the default for the whole varargs tuple at once (although arguably
    that should just be the non-`...` behavior, but that'd be too
    breaking a change). Ref #50518. However, for other arguments,
    there isn't really a sensible semantic meaning. This PR disallows
    this in lowering. This is technically a minor change, but I doubt
    anybody is using this. Splatting in default values wasn't really
    ever supposed to work anyway, it just happened to fall out of
    our lowering.
    Keno committed Jul 15, 2023
    Configuration menu
    Copy the full SHA
    b5bb8f3 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2023

  1. Apply suggestions from code review

    Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
    Keno and JeffBezanson authored Jul 17, 2023
    Configuration menu
    Copy the full SHA
    6fe6cf2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f2c46c5 View commit details
    Browse the repository at this point in the history
  3. Adjust error message in test

    Keno committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    69d7385 View commit details
    Browse the repository at this point in the history