swiftlang/swift

[SR-5457] Specific error message when user tries to compile Swift executable

开放

#48,029 创建于 2017年7月14日

 (2 条评论) (0 个反应) (0 位负责人)Swift (10,719 个派生)batch import
compilergood first issueimprovementparser

仓库指标

星标
 (69,989 个星标)
PR 合并指标
 (平均合并 8天 17小时) (30 天内合并 510 个 PR)

描述

Previous ID SR-5457
Radar None
Original Reporter carlb (JIRA User)
Type Improvement
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.

贡献者指南