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-8507] 'foo bar' could have fixit suggesting missing . rather than just ; or , #51027

Open
huonw mannequin opened this issue Aug 10, 2018 · 2 comments
Open

[SR-8507] 'foo bar' could have fixit suggesting missing . rather than just ; or , #51027

huonw mannequin opened this issue Aug 10, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself good first issue Good for newcomers parser Area → compiler: The legacy C++ parser

Comments

@huonw
Copy link
Mannequin

huonw mannequin commented Aug 10, 2018

Previous ID SR-8507
Radar rdar://problem/25290712
Original Reporter @huonw
Type Bug
Environment

Master at 2018-08-09

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser, StarterBug
Assignee None
Priority Medium

md5: 2e0b2de995cd56da9923536462d8ef0c

Issue Description:

For instance, in the following code, the mistake is missing the ., not missing a ;

struct Foo {
    var bar = 0
}

let foo = Foo()

let something = 1 + foo bar 
foo bar = 1
print(foo bar)

The errors for each of the three invalid lines are:

space.swift:7:24: error: consecutive statements on a line must be separated by ';'
let something = 1 + foo bar 
                       ^
                       ;
space.swift:7:19: error: binary operator '+' cannot be applied to operands of type 'Int' and 'Foo'
let something = 1 + foo bar 
                ~ ^ ~~~
space.swift:7:19: note: expected an argument list of type '(Int, Int)'
let something = 1 + foo bar 
                  ^
space.swift:7:25: error: use of unresolved identifier 'bar'
let something = 1 + foo bar 
                        ^~~
space.swift:8:4: error: consecutive statements on a line must be separated by ';'
foo bar = 1
   ^
   ;
space.swift:8:1: warning: expression of type 'Foo' is unused
foo bar = 1
^~~
space.swift:8:5: error: use of unresolved identifier 'bar'
foo bar = 1
    ^~~
space.swift:9:11: error: expected ',' separator
print(foo bar)
          ^
         ,
space.swift:9:11: error: use of unresolved identifier 'bar'
print(foo bar)
          ^~~

If it looks like an property access (or even a method call) might be valid (i.e. the thing after the space is an identifier), the compiler could guess at using . rather than/as well as ; or ,.

@belkadan
Copy link
Contributor

Resetting assignee for all Starter Bugs not touched since 2018.

@LucianoPAlmeida
Copy link
Contributor

I can take this one if there's no assignee yet @belkadan 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 itself good first issue Good for newcomers parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants