-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfperformance
Description
| Previous ID | SR-11857 |
| Radar | rdar://problem/57494816 |
| Original Reporter | @Lukasa |
| Type | Bug |
Environment
Linux Swift 5.1
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, Performance |
| Assignee | None |
| Priority | Medium |
md5: 263a33d97196a85107a6e2fdad176491
Issue Description:
When holding on to an optional local variable, Swift is unable to infer that if one force unwrap of that variable succeeds, all others must succeed as well. There are some potentially invalidating operations that would prevent this optimisation (e.g. calling a mutating function on the Optional), but in simple cases this should be entirely safe to optimise.
Here is a compiler explorer link with an example of the bug in the decodeLoop function.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfperformance