chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 418 forks source link

[Bug]: Calling an `extern proc` with an invalid number of arguments results in an internal error #25731

Open jabraham17 opened 1 month ago

jabraham17 commented 1 month ago

Summary of Problem

Description: Incorrectly specifying and calling an extern function results in an internal error with the LLVM backend. If CHPL_DEVELOPER is set or --verify is used, the internal error is replaced by a LLVM verification error.

Using the C backend gets a nicer error during codegen: too few arguments to function call, single argument 'x' was not specified. However since this error comes from the C backend compiler, there error is about foo.c instead of foo.chpl.

Steps to Reproduce

Source Code:

foo.chpl

require "lib.h";
extern proc func();
func();

lib.h

void func(int x);

lib.c

void func(int x) { }

Compile command: chpl foo.chpl lib.c

Configuration Information

bradcray commented 1 month ago

It would be difficult to improve the situation for the C back-end without having our compiler parse .h files and validate that extern declarations match the C declarations.

The LLVM back-end effectively does this, (which is presumably what results in the internal error in developer/verify mode?), so seems more directly addressable.