Skip to content

Bad signature for main asserts #3617

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

Closed
ben0x539 opened this issue Sep 28, 2012 · 4 comments
Closed

Bad signature for main asserts #3617

ben0x539 opened this issue Sep 28, 2012 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@ben0x539
Copy link
Contributor

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.

@graydon
Copy link
Contributor

graydon commented Oct 3, 2012

Short term fix for you is just not to have args in your main function; we only support one non-empty variant (takes an owned vector of owned strings) and we're removing that in favour of a runtime call to fetch the command line args.

Of course, this is also a terrible error message. Tagging as diagnostic-related.

@brson
Copy link
Contributor

brson commented Oct 4, 2012

The bad error message is fixed now. Assert is not.

@catamorphism
Copy link
Contributor

Not critical for 0.6. De-milestoning.

@bstrie
Copy link
Contributor

bstrie commented May 13, 2013

Since the original bug is fixed, closing this in favor of #6451.

@bstrie bstrie closed this as completed May 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

5 participants