[SR-12093] Checked Casts With Literals Are Deeply Unintuitive #54529
Labels
casting
Feature: explicit casting (is, as, as? and as!)
compiler
The Swift compiler in itself
improvement
literals
Feature → expressions: Literals such as an integer or string literal
swift evolution proposal needed
Flag → feature: A feature that warrants a Swift evolution proposal
Additional Detail from JIRA
md5: f23b80191801a31166f6b799915c7a23
cloned from:
Issue Description:
Checked casts on literals can have surprising effects at face value
The former is a character literal and is statically coerced. The latter is a String literal that is being dynamically cast to a Character. This cast will always fail, and we note as much - this also works with as! force casts.
This behavior is deeply unintuitive and should be revisited by a proposal to unify casting semantics for literals.
The text was updated successfully, but these errors were encountered: