Commit Graph

59 Commits

Author SHA1 Message Date
David Farler
47c043e8a6 Disallow 'var' specifier in for-in patterns
Don't allow a pattern like:

  for var x in sequence {
    ...
  }

and provide a removal fix-it for the 'var' keyword.

Additionally, for the following code:

  for let x in sequence {
    ...
  }

Provide a removal fix-it since the 'let' specifier is now
redundant.

rdar://problem/23172698

Swift SVN r32818
2015-10-22 00:46:25 +00:00
Chris Lattner
ada5487153 add fixit tests to random other tests.
Swift SVN r31006
2015-08-04 20:35:36 +00:00
Chris Lattner
16b4ad5ce1 Generalize r29106 to handle all of the different kinds of statements that have patterns
in a more robust way.  Also, add testcases for them all.



Swift SVN r29199
2015-06-01 02:52:30 +00:00
Chris Lattner
dd594f6790 fix <rdar://problem/21091625> Bogus 'never mutated' warning when protocol variable is mutated only by mutating method
we need special magic to look through OpaqueValueExprs.



Swift SVN r28994
2015-05-24 21:16:36 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Chris Lattner
9bbce68ec8 fix <rdar://problem/20894455> "variable was never mutated" diagnostic does not take #if into account
Swift SVN r28633
2015-05-15 18:30:32 +00:00
Chris Lattner
1e934dd432 fix <rdar://problem/20927707> QoI: 'variable was never mutated' noisy when only part of a destructured tuple is mutated
If a 'var' pattern binding contains multiple vardecls and some are mutated
but others aren't, don't warn about the non-mutated ones as being potential 
candidates for 'let's since there is no great way to rewrite the code to
silence the warning.


Swift SVN r28629
2015-05-15 17:48:34 +00:00
Chris Lattner
5685121505 fix <rdar://problem/20911927> False positive in the "variable was never mutated" warning with IUO
Swift SVN r28583
2015-05-14 22:13:08 +00:00
Chris Lattner
ddd6192094 Implement 3 prominent feature requests:
<rdar://problem/15975935> warning that you can use 'let' not 'var'
<rdar://problem/18876585> Compiler should warn me if I set a parameter as 'var' but never modify it
<rdar://problem/17224539> QoI: warn about unused variables

This uses a simple pass in MiscDiagnostics that walks the body of an
AbstractFunctionDecl.  This means that it doesn't warn about unused properties (etc),
but it captures a vast majority of the cases.

It also does not warn about unused parameters (as a policy decision) because it is too noisy,
there are a variety of other refinements that could be done as well, thoughts welcome.



Swift SVN r28412
2015-05-11 06:26:05 +00:00