Skip to content

Statics shadow local variables causing "refutable pattern error", and non-obvious bugs. #7526

Closed
@huonw

Description

@huonw
rusti> static a: uint = 1;
rusti> let a = 2;
<anon>:29:4: 29:5 error: only refutable patterns allowed here
<anon>:29 let a = 2;
              ^

A particularly insidious example is:

static a: uint = 1;
// ... hundreds of lines of code/several modules later ...
match (1u,2u) {
   (1, a) => println(a.to_str()),
   (x, y) => println((x+y).to_str())
}

since one could easily imagine not noticing that the first arm doesn't run, and/or spending hours debugging it.

(#7523 added an lint enforcing statics as uppercase, warn'd by default, which makes this less likely to occur. There was some discussion about turning this to allow by default if/when the error messages are improved. Update 2013-7-22: has been turned to allow but there is no improvement in error messages.)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions