[swift-evolution] Prohibit invisible characters in identifier names

Jordan Rose jordan_rose at apple.com
Mon Jun 20 19:22:11 CDT 2016


IIRC, some languages require zero-width joiners (though not zero-width spaces, which are distinct) to properly encode some of their characters. I'd be very leery of having Swift land on a model where identifiers can be used with some languages and not others; that smacks of ethnocentrism.

Jordan


> On Jun 20, 2016, at 10:51, João Pinheiro via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Recently there has been a screenshot going around Twitter about C++ allowing zero-width spaces in variable names. Swift also suffers from this problem which can be abused to create ambiguous, misleading, and potentially obfuscate nefarious code.
> 
> I would like to propose a change to prohibit the use of invisible characters in identifier names.
> 
> I'm including an example of problematic code at the bottom of this email.
> 
> Sincerely,
> João Pinheiro
> 
> 
> /* The output for this code is:
> A
> B
> C
> 1
> 2
> 3
> */
> 
> 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
> 
> test()
> t​est()
> te​st()
> 
> print(abc)
> print(a​bc)
> print(ab​c)
> _______________________________________________
> 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/20160620/376e8c09/attachment.html>


More information about the swift-evolution mailing list