Skip to content

Bad signature for main asserts #3617

@ben0x539

Description

@ben0x539

Given an invalid definition of main, like fn main(a: int) {}, rustc complains, and suggests:

foo.rs:1:0: 1:18 error: Wrong type in main function: found `fn(int)`, expected `extern fn(++v: ~[~str]) -> ()` or `extern fn() -> ()`

Naively, I went and put extern fn main() {} or even extern fn main(++args: ~[~str]) {} in my code, including the spurious extern, and now rustc chokes on it:

rustc: [...]/rust/src/llvm/lib/VMCore/Instructions.cpp:275: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
Aborted

Neither of these messages should happen quite like that. :)

This is on commit b68d287 on the incoming branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions