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-5457] Specific error message when user tries to compile Swift executable #48029

Open
swift-ci opened this issue Jul 14, 2017 · 2 comments
Open
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5457
Radar None
Original Reporter carlb (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, Parser, StarterBug
Assignee None
Priority Medium

md5: 111feeb80ab569e4bee27d9d511be231

Issue Description:

I was talking to a new Swift programmer who came from the ruby/python world. He had this output:

$ swift .build/debug/helloWorld
.build/debug/helloWorld:1:1: error: invalid UTF-8 found in source file
�����x� H__PAGEZERO8__TEXT@@__text__TEXT Ͷ �__stubs__TEXT��
.build/debug/helloWorld:1:2: error: invalid UTF-8 found in source file
�����x� H__PAGEZERO8__TEXT@@__text__TEXT Ͷ �__stubs__TEXT��
.build/debug/helloWorld:1:3: error: invalid UTF-8 found in source file
�����x� H__PAGEZERO8__TEXT@@__text__TEXT Ͷ �__stubs__TEXT��
.build/debug/helloWorld:1:4: error: input files must be encoded as UTF-8 instead of UTF-16
�����x� H__PAGEZERO8__TEXT@@__text__TEXT Ͷ �__stubs__TEXT��

Because he had started with Swift scripts, where you put swift in front of the file.swift name.

The error message above is perfectly valid, but unhelpful in this case. I would guess enough new programmers would make this mistake that it's worth discussing a special-case error message if the file to be run is already a Swift executable.

@belkadan
Copy link
Contributor

Interesting! I think the best way to do this would be to check for various executable formats' "magic numbers" at the start of a source buffer. "\xCA\xFE\xBA\xBE" and "\x7fELF" would handle both Mach-O and ELF executables (Darwin and Linux/BSD).

@belkadan
Copy link
Contributor

Resetting assignee on all Starter Bugs not modified since 2018.

@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
compiler The Swift compiler in itself good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants