Open Aniket21mathur opened 4 years ago
@mppf @lydia-duncan keeping you guys in the loop.
Hi @Aniket21mathur: It's not clear to me what you're requesting here. A slight variation on your example seems to be working on Chapel 1.20 (https://tio.run/##bY/BDoIwDIbve4o/nDQxQTyyePUBiHezQEGSOZYy9EB49rkx8OSp/dq/7d/6qSxp75nqgRuQmV53Gh1mIYA8x60n3SBreepdhlB7K8ZKjzLFEVcUZUplEFge6tTBDCY3sdkGJJa9z9Rumpj90QVh9LKfmAMDylpN4dz5tOLARnWRi8Qdh1@inUvkRYQt0W1V/t6S4sO9I20O1VF6/wU) and master:
record enumTest {
// Field "fruit"
var fruit_: fruits = 1:fruits;
proc fruit { return fruit_; }
proc ref fruit ref { return fruit_; }
enum fruits {
apple = 0,
ornage = 1,
grapes = 2,
}
}
var R: enumTest;
writeln(R);
Have you found another case that does not?
Hii @bradcray, thanks for looking into this!
Try something like this ->
record enumTest {
// Field "fruit"
var fruit_: fruits = 0:fruits;
proc fruit { return fruit_; }
proc ref fruit ref { return fruit_; }
proc test() {
var t;
t = 2:fruits;
}
enum fruits {
apple = 0,
ornage = 1,
grapes = 2,
}
}
var R: enumTest;
R.test();
It throws the internal error message
test.chpl:10: internal error: UTI-MIS-0691 chpl version 1.23.0 pre-release (f67842f0f8)
Note: This source location is a guess.
Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
OK, thanks. This looks related to #6871.
As a workaround for the time being, can your translation move the enum outside of the record? (possibly munging it with the record name to ensure that it's unique?). Not as elegant, obviously, but may prevent this from blocking you.
As a workaround for the time being, can your translation move the enum outside of the record? (possibly munging it with the record name to ensure that it's unique?). Not as elegant, obviously, but may prevent this from blocking you.
Yes, we can do that. Thanks :)
Summary of Problem
While working on adding support for nested enums in messages for protocol buffers, we came to a point to put this feature to discussion. In Chapel, each
proto
message gets converted into a record. So if we have a nested enum in the message, it might be fair if we have a nested enum in the corresponding generated record as well.For example->
proto
fileA part of the generated file ->