[swift-evolution] Prohibit invisible characters in identifier names

João Pinheiro joao at joaopinheiro.org
Thu Jun 23 17:03:03 CDT 2016

This was exactly the motivation for the proposal and a similar example was given on the first email of the thread.

Try this:

func test() { print("A") }
func t​est() { print("B") }
func te​st() { print("C") }

let abc = 1
let a​bc = 2
let ab​c = 3



João Pinheiro

> On 23 Jun 2016, at 22:59, Josh Wisenbaker via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jun 23, 2016, at 4:45 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> Let me correct myself: what I think Josh's example is should be corrected whether we prohibit or ignore. However, since no one can see the invisible characters he used, I can't say for sure.
>> If he found a clever way to reorder or change spacing between letters (e.g. superimpose two characters so that "var11" looks like "var1"), then the problem can only be fixed by prohibition.
> I asked my colleague who played the prank on me and got the details:
> "Lines 4 and 5 declare variables with embedded Unicode Zero Width Spaces (U+200B) in their names. Line 4 is actually  “var\U+200B1”, not “var1”. Isn’t it nice of Swift to be this flexible 😊”
> Josh
> Josh Wisenbaker
> macshome at mac.com <mailto:macshome at mac.com>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160623/9957b071/attachment.html>

More information about the swift-evolution mailing list