chapel-lang / chapel

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

Can't init a shared nilable field in a generic record or class... #15846

Closed GordonBGood closed 4 years ago

GordonBGood commented 4 years ago

Summary of Problem

As the title says and as per the source code below.

Steps to Reproduce

Source Code:

class C {  }

record Test { // generic; could also be class...
    type rslttype;
    var rt: rslttype? = nil: rslttype?; // same error for default case!
}

var tst = new Test(shared C); // compiler bug/error for shared!!!

// need to use unmanaged and convert it to shared using shared.create() later!!!!!
// var tst = new Test(unmanaged C); // this works
writeln(tst);

Error on compilation for the "shared" case: BUG.chpl:5: internal error: AST-EXP-0433 chpl version 1.22.0

Internal errors indicate a bug in the Chapel compiler ("It's us, not you"), and we're sorry for the hassle. We would appreciate your reporting this bug -- please see https://chapel-lang.org/bugs.html for instructions. In the meantime, the filename + line number above may be useful in working around the issue.

Run output with the work-around of using "unmanaged": (rt = nil)

Note, to use this ability currently, I am making the type of the generic to be an "unmanaged" and converting the field to a "shared" using shared.create(), but it is more awkward and there is a significant chance that if one forgets or does it incorrectly, there will be a memory leak. For instance, one can not designate the return types of some methods due to this and must allow them to be inferred from the instanciated type.

Compile command:

With the test file named "bug.chpl", compile with chpl bug.chpl.

Execution command:

./bug when it compiles, but the problem is with compilation...

Configuration Information

mppf commented 4 years ago

hi @GordonBGood - thanks for filing this issue. I've been able to reproduce the problem and I'm investigating.

bradcray commented 4 years ago

@GordonBGood: This is completely off-topic, but I'm not sure I have a better way to contact you: A colleague pointed out your Nim and Chapel comparison this morning, and I posted some follow-up questions and comments on it, but they haven't gotten through the moderator queue last I checked. I'll leave it at that for now, but if they don't show up in a few days, maybe I could get a copy of them to you over Gitter or by email (?).

GordonBGood commented 4 years ago

That was fast, thank you.

On Tue, Jun 16, 2020, 06:23 Michael Ferguson notifications@github.com wrote:

Closed #15846 https://github.com/chapel-lang/chapel/issues/15846 via

15848 https://github.com/chapel-lang/chapel/pull/15848.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chapel-lang/chapel/issues/15846#event-3446584359, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRTMTIYP2GAFJWPOIETGELRW2UP7ANCNFSM4N6Y6JDA .

GordonBGood commented 4 years ago

Hi Brad(@bradcray), I was hoping to be able to get in more direct contact with you eventually; happy that the occasion is now. Pleased to meet you.

If you have discussion about my post on the Nim forum related to any errors or omissions on my part (which I would be happy to correct), that is the better place to post them, but as you say, there is a delay of a day or two in joining the forum, so meanwhile we can correspond and I'll correct anything glaring on your behalf.

I am reluctant to post my email address in a public place such as this, but I am active on StackOverflow (where I see you are too) and RosettaCode so you could have contacted me through talk pages there. However, I see your email address at hpe and will contact you through that. There will be some delay in discussions with you in Seattle, most of the Nim people in Europe, and me in Thailand, but we'll get it done.

I will be most interested to see your comments and questions on my Nim forum post. In the meantime, you might like to look at some Chapel code I posted on RosettaCode re Hamming Numbers sequence: http://rosettacode.org/wiki/Hamming_numbers#Chapel and the Sieve of Eratosthenes: http://rosettacode.org/wiki/Sieve_of_Eratosthenes#A_Multi-Threaded_Page-Segmented_Odds-Only_Bit-Packed_Version. This last is a bit long for posting there, but I wanted to show Chapel's strength in efficiently running things in parallel.

I'll be in touch.

On Tue, Jun 16, 2020, 05:47 Brad Chamberlain notifications@github.com wrote:

@GordonBGood https://github.com/GordonBGood: This is completely off-topic, but I'm not sure I have a better way to contact you: A colleague pointed out your Nim and Chapel comparison this morning, and I posted some follow-up questions and comments on it, but they haven't gotten through the moderator queue last I checked. I'll leave it at that for now, but if they don't show up in a few days, maybe I could get a copy of them to you over Gitter or by email (?).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chapel-lang/chapel/issues/15846#issuecomment-644428030, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRTMTMBLK5WTTKEAJEF3ADRW2QHNANCNFSM4N6Y6JDA .