-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lint] Double force casting #217
Comments
Doesn't this work as expected:
|
I think problem is: But I think this should be only allowed to written as : pub fun main(): AnyStruct {
let bin: {String: String} = { "gg": "10" }
var v : {String: AnyStruct?} = { "deniz": bin["gg"] }
let thing = v["deniz"]!!.getType()
return thing
} But as |
Yeah, that's what I tried to point out: The analysis works only on static types, and from that perspective the implementation is correct. However, you're right that So the analysis could be improved here to ignore |
In particular, the exception should be added here: cadence-tools/lint/unnecessary_force_analyzer.go Lines 59 to 60 in 55644ee
|
Current Behavior
Right now if you double force cast, for example,
test["testing"]!!
, the linter will tell you that you are performing anunecessary force unwrap
.However, given the fact that it's possible for dictionaries to have
nil
values, this actually may be needed some times to convert, for example, aString??
to aString
Expected Behavior
The linter should not complain about a double force cast if the type is a double optional
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: