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

Confusing compiler error when binding an anonymous function to a global variable with the wrong type. #310

Open
cianoc opened this issue Jan 6, 2018 · 2 comments

Comments

@cianoc
Copy link
Contributor

cianoc commented Jan 6, 2018

When running the following code:

(bind-func my-closure
  (lambda (x:i64)
    (lambda (y) (+ x y))))

(bind-val f [i64*,i64*]* (myclosure 4))

($ (f 5)) ;; this triggers the error

I get the following message from the compiler:

Compiler Error  compiler failed
**** DECL ****
@f = external global { i8*, i8*, i64* (i8*, i8*, i64*)* }**
declare %mzone* @llvm_pop_zone_stack ()
declare void @llvm_zone_destroy (%mzone*)
declare i8* @malloc (i64)
declare i8* @memset (i8*, i32, i64)
declare i8* @strcpy (i8*, i8*)
declare %String* @toString_poly_W1N0cmluZyosaTY0Kl0q (i64*)
declare %String* @zcopy_adhoc_W1N0cmluZyosU3RyaW5nKixtem9uZSosbXpvbmUqXQ (%String*, %mzone*, %mzone*)
declare i8* @zcopy_poly_W2k4KixpOCosbXpvbmUqLG16b25lKl0q (i8*, %mzone*, %mzone*)
**** ENDDECL ****

LLVM IR: <string>:150:32: error: '%f1071' defined with type 'i64* (i8*, i8*, i64*)*'
%result1076 = call fastcc i64* %f1071(i8* %z1075, i8* %e1072, i64 5)
                               ^
@digego
Copy link
Owner

digego commented Jan 7, 2018 via email

@cianoc cianoc changed the title Compiler error when defining an anonymous closure Confusing compiler error when binding an anonymous function to a global variable with the wrong type. Jan 8, 2018
@cianoc
Copy link
Contributor Author

cianoc commented Jan 8, 2018

I think the error message should say something like f was expected a type of X, but instead got a type of Y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants