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-6624] Incorrect error although build is successful in recent dev snapshots #49173

Closed
jepers opened this issue Dec 15, 2017 · 9 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@jepers
Copy link

jepers commented Dec 15, 2017

Previous ID SR-6624
Radar rdar://problem/36113282
Original Reporter @jepers
Type Bug
Status Closed
Resolution Done
Environment

Xcode 9.2 using toolchain dev snapshot 2017-12-12 or later

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee @benlangmuir
Priority Medium

md5: e24d6c1d190b78a80ee9afc0c88e22fa

Issue Description:

Steps to reproduce:

  1. Make sure you are using Xcode 9.2 and toolchain dev snapshot 2017-12-12 or later.

  2. Start a new Command Line App project.

  3. Being in the main.swift file, press Build, note that it builds as expected.

  4. Add another swift file to the project (eg Other.swift), content doesn't matter.

  5. Go back into main.swift and Build again, note that it builds successfully BUT the IDE will show an "Expressions are not allowed at the top level"-error on the line with print("Hello, world!"). And the error message will not go away if you clean etc.

  6. Note that if you go into the Other.swift file and Build, you'll not see any error.

The issue will go away if I select an earlier toolchain I have (2017-12-09), and it comes back again if I reselect 2017-12-12.

@belkadan
Copy link
Contributor

@benlangmuir, sounds like Live Issues aren't equipped to deal with a main.swift file in a multi-file project?

@jepers
Copy link
Author

jepers commented Dec 18, 2017

Tried with dev snapshot 2012-12-17 and the issue remains.

@belkadan
Copy link
Contributor

@swift-ci create

@jepers
Copy link
Author

jepers commented Feb 7, 2018

Seems to have been fixed in Xcode 9.3 beta 2?

@jepers
Copy link
Author

jepers commented Feb 23, 2018

But it's back in Xcode 9.3 beta 3 (and, in my current case right now, dev snapshot 2018-02-21, but I haven't tested other snapshots).

@jepers
Copy link
Author

jepers commented Feb 26, 2018

Issue remains in dev snapshot 2018-02-25 (with Xcode 9.3 beta 3).

@jepers
Copy link
Author

jepers commented Feb 26, 2018

Perhaps this bug should be filed as a radar instead?

@benlangmuir
Copy link
Member

This is sourcekitd. I can reproduce in the 2017-12-12 snapshot but not the 12-11 one. The only change to sourcekitd in that timeframe was https://github.com/apple/swift/pull/13268 . It's easy to reproduce from the command-line:

$ cat main.swift
print("")

$ touch other.swift
$ swiftc `pwd`/main.swift `pwd`/other.swift -module-name main -c ## OK
$ sourcekitd-test -req=sema `pwd`/main.swift -- `pwd`/main.swift `pwd`/other.swift -module-name main
<snip>
    key.severity: source.diagnostic.severity.error,
    key.description: "expressions are not allowed at the top level",

@benlangmuir
Copy link
Member

#14864

@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.
Projects
None yet
Development

No branches or pull requests

3 participants