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

[SR-2242] QoI: poor diagnostic when argument label is omitted #44849

Closed
rudkx opened this issue Aug 1, 2016 · 6 comments
Closed

[SR-2242] QoI: poor diagnostic when argument label is omitted #44849

rudkx opened this issue Aug 1, 2016 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@rudkx
Copy link
Member

rudkx commented Aug 1, 2016

Previous ID SR-2242
Radar rdar://problem/27212391
Original Reporter @rudkx
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @rudkx
Priority Medium

md5: 5fc39c2b102d27d0dd480337f34cfad1

Issue Description:

We currently emit:

  error: unnamed argument #​2 must precede unnamed argument #​1

for the following, which isn't reasonable, because the real issue here is that argument label x: is missing. If you actually swap the arguments you get the exact same error.

func unnamed(x: Int, _ y: Int) -> Int {
  return x + y
}

func test() -> Int {
  return unnamed(3, 5)
}
@rudkx
Copy link
Member Author

rudkx commented Aug 1, 2016

@rintaro, you've recently been working on improvements here. Is this something you'd be willing to look at soon?

If not feel free to assign back to me.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 2, 2016

@rudkx I'm aware of this bug. The test case was already in the repo: 612991e.
before I started working around here.

I guess there is something wrong in constraints::matchCallArguments in lib/Sema/CSSimplify.cpp.
But, unfortunately, I don't have time to look into this right now. 🙁

@rudkx
Copy link
Member Author

rudkx commented Sep 21, 2016

I think this may be related:

func foo(x: Int, _ y: Int) -> Int { return x + y }

_ = foo(1, y: 2)

results in:

order.swift:3:12: error: argument 'y' must precede unnamed argument #​1
_ = foo(1, y: 2)
        ~  ^~~~
        y: 2 1

@jtbandes
Copy link
Collaborator

Yeah, that's the exact same issue.

I took a brief look yesterday and indeed, matchCallArguments is the culprit here.

Basically, when the first argument doesn't match, it moves on to the second, which steals the first unmatched parameter, so in the final cleanup it thinks they're out of order.

Might be nice to rework this by starting with a simple handful of test cases with desired behavior.

@rudkx
Copy link
Member Author

rudkx commented Sep 22, 2016

Yeah, I assumed it was the same issue but since I haven't looked too closely at the code didn't want to state it as a fact.

@rudkx
Copy link
Member Author

rudkx commented Sep 24, 2016

A fix was merged into master: 366a3a0

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants