Skip to content
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

ICE on completely bogus use of ref in closure parameter list #5239

Closed
ben0x539 opened this issue Mar 5, 2013 · 5 comments
Closed

ICE on completely bogus use of ref in closure parameter list #5239

ben0x539 opened this issue Mar 5, 2013 · 5 comments
Labels
A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ben0x539
Copy link
Contributor

ben0x539 commented Mar 5, 2013

I was overly optimistic regarding rustc's current DWIM semantics, and rustc didn't even know how to exhaustively describe my stupidity.

foo.rs:1:22: 1:28 error: the type of this value must be known in this context
foo.rs:1 fn main() { |ref x| { x += 1; }; }
                               ^~~~~~
error: internal compiler error: no type for node 9: expr 1 (id=9) in fcx 7f86d428df40
@nikomatsakis
Copy link
Contributor

Yeah, interesting! We should probably prevent ref modes in argument patterns altogether.

@ben0x539
Copy link
Contributor Author

The original example doesn't seem to throw an ICE anymore. The following still crashes the compiler:

fn main() { 
    let _f: &fn(int) -> int = |ref x: int| { *x };
}

rustc: /home/ben/code/repos/rust/src/llvm/include/llvm/Support/Casting.h:197: typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X = llvm::PointerType; Y = llvm::Type_; typename llvm::cast_retty<To, From>::ret_type = llvm::PointerType_]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
Aborted

Seems to be a bit uncertain whether my bogus parameter is a pointer or not.

@emberian
Copy link
Member

New example still reproduces:

rustc: ../../../../../src/llvm/include/llvm/Support/Casting.h:231: typename enable_if<is_same<Y, typename simplify_type<Y>::SimpleType>, typename cast_retty<X, Y *>::ret_type>::type llvm::cast(Y *) [X = llvm::PointerType, Y = llvm::Type]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
zsh: abort (core dumped)  rustc foo.rs

@metajack
Copy link
Contributor

This was apparently fixed. Closing.

@emberian
Copy link
Member

Reopening, needstest.

@emberian emberian reopened this Aug 26, 2013
bors added a commit that referenced this issue Aug 29, 2013
I've added a test for the second example mentioned in #5239. The first example does not compile with a reasonable error message. Should I add a compile-fail test for that example as well?

    /rust/src/test/run-pass/issue-5239.rs:15:45: 15:51 error: binary operation + cannot be applied to type `&int`
    rust/src/test/run-pass/issue-5239.rs:15     let _f = |ref x: int| { x += 1};
                                                                                         ^~~~~~

    error: aborting due to previous error
@bors bors closed this as completed in 8557219 Aug 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants