rust icon indicating copy to clipboard operation
rust copied to clipboard

Using 'type' as parameter name doesn't work

Open ttaubert opened this issue 14 years ago • 3 comments

I tried to declare a function such as:

fn func(type: int) -> int;

This gave me the error "found type in expression position". Shouldn't I be able to use 'type' as a parameter name?

ttaubert avatar Jan 30 '12 09:01 ttaubert

This is not allowed. It would make the following code difficult to parse:

fn foo(&type: int) {
    type mytype = int;
    type += 1;
}

marijnh avatar Jan 30 '12 10:01 marijnh

Hmm ok :( I guess that'll be quite a banana skin for some people.

ttaubert avatar Jan 30 '12 10:01 ttaubert

The manual has a list of keywords in Rust:

http://doc.rust-lang.org/doc/rust.html#keywords

catamorphism avatar Jan 30 '12 18:01 catamorphism