swift
aba6b929 - Adding actionable note to @main error

Commit
3 years ago
Adding actionable note to @main error The compiler enters "script" mode if there is a file called `main.swift`, or if there is only one file. Parsing files as a script means that anything in the file is interpreted as top-level code, which is incompatible with a valid @main-annotated struct, so an error is emitted. Unfortunately, it is intentional in many cases, and the diagnostic didn't provide anything actionable to indicate that the explicit main function is intentional and that the file being passed in is not actually a top-level context. The new note indicates that passing `-parse-as-library` to the compiler invocation will fix it if the explicit main function is intentional.
Author
Parents
Loading