-
Notifications
You must be signed in to change notification settings - Fork 2
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
First Class Functions and Type System #3
Comments
I managed to 'fix' (read: work around) the issues with function pointers by inserting the logic inline with the code for In reality, I'm spent an entire day working on getting back to where I was before because of some technical difficulties in the compiler, and it's extremely frustrating as evaluations are just around the corner :( |
Can confirm: While compiling it by itself does not yield a crash, compiling it with other files causes the following internal error:
So any first class functions cause internal compiler issues. So unfortunate though. |
OK, relax :) Compile with --devel, it'll show you the assert that triggers in compiler. How do I reproduce this? Tell me more and I can play around/create an issue if necessary. |
Wow... so |
Alternatively, you can set environment variable CHPL_DEVELOPER=1... Sometimes it is a bit confusing though, because when there is a user error, it will generally show the exact Also, are you able to workaround your problem now? Or should I still take a look at it? (It may have to wait until tomorrow) |
You've done more than enough Engin, I should be able to diagnose and resolve any other issues I have for now! Greatly appreciate it! |
No problem! It'd still be nice to see what was to problem and create a bug report if necessary, though. If you can get to the bottom of the problem (a minimal snippet, for example) let me know.. |
I see it! The issue! It seems that... it wasn't... even my code? When I have included Create a simple file with just For reference, I have it here as a gist. This leaves me at such a loss, because I'm not sure if the issue was ever present in first class functions... meaning I wasted so much time... Output:
Output w/ Developer Debug:
|
|
Do you think this bug is specific to the |
Yes. There are interesting pragmas in BigInteger, that by looking at their names control something that may be triggering this problem. I am pretty sure this is a bug, but a super corner case bug. |
There's another issue with first class functions, but at this point would you prefer I make an actual issue of it on Chapel's issue tracker? I tried making a minimal, but reasonable/practical application of it in the example: here. If you want to see if its worthwhile of being a bug, that's fine too. |
Firstly, minimal working example(MWE) doesn't need to be practical at all, at least for bug reports. Here is a true MWE of the code you have: proc foo() {
var a: [{1..10}] int;
return lambda(n:int) { return a[n]; };
}
writeln(foo()(1)); I think any internal bug error that you get without --devel is important to record for Chapel's development. When it comes to this one the issue is probably missing compiler error message. The problem occurs because you are using an array in the nested lambda and returning it. Now since you are using the outer array In sum, I think this is user error where compiler doesn't do a good job detecting it. You cannot use outer-local variables in a nested lambda and return it, because those variables will be reclaimed once the outer function returns the inner lambda. From a more philosophical standpoint, lambdas/function pointers shouldn't be used for such complicated cases in a language like Chapel, because things get elusive and error-prone quite easily. |
I guess really I have to actually give up the usage of any lambdas (especially for my use cases). I'm amazed that you could find the root cause so quickly. I'll add any other bugs I find to issue #9 |
One thing I'm going to concede here is that cclock can't be improved at this point in time. The
object
class is the only way to do this, and any other way produces annoying and frustrating compiler errors (internal) or syntax errors which lead to paradoxes (like Chicken-And-The-Egg, except with types) where if you don't know the type at initialization time, or if the type can change, it just won't work. In this way, only class instances can work, which require wrapper objects. I spent far too long on attempting to improve it, I'll try later.The text was updated successfully, but these errors were encountered: