swiftlang/swift

[SR-14941] Introduce compiler warning for leading-zero octal notation

Open

#57,283 opened on Jul 19, 2021

View on GitHub
 (13 comments) (0 reactions) (1 assignee)Swift (10,719 forks)batch import
good first issueimprovement

Repository metrics

Stars
 (69,989 stars)
PR merge metrics
 (Avg merge 8d 17h) (510 merged PRs in 30d)

Description

Previous ID SR-14941
Radar rdar://problem/22123688
Original Reporter eaigner (JIRA User)
Type Improvement
Votes 0
Component/s
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: 639a9bd96ac9c3918c5433098fa9ad29

Issue Description:

I had a bug in my code for quite some time that went by unnoticed, because I didn't realize Swift handled octal numbers differently. Specifically I was making the following call

mkfifo(path, 0644)

This should obviously read `0o644`, but went by unnoticed, since it just resulted in an elevated user permission.

It would be great if the compiler could warn in such instances where numbers are typed with leading zeroes, maybe something of the form "Did you mean to write an octal number?"

Contributor guide