~sircmpwn/hare#741: 
Cannot export an error type of an enum

With a main.ha of

use module;

export fn main() void = void;

and a module/module.ha of

export type foo = enum {
	ONE,
};

export type error = !foo;

export fn get() (void | error) = void;

attempting to compile with hare build complains:

Cannot use unexported type !module::foo in exported declaration 'module::error'
Error: harec: exited with status 1
hare build: build failed

Despite the fact that foo is in fact exported.

This works if error is not defined as an error type.

The problem is only with enums; this works if foo is defined instead as a scalar, slice, struct, or union.

Status
RESOLVED FIXED
Submitter
~smlavine
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
bug harec

~smlavine 2 years ago

I believe I've narrowed done the problem to this case in emit_type(): https://git.sr.ht/~sircmpwn/harec/tree/master/item/src/typedef.c#L301

With some print debugging I have determined that type->alias.exported is not set for foo. Therefore emit_type() returns false when called below, here: https://git.sr.ht/~sircmpwn/harec/tree/master/item/src/typedef.c#L329

Furthermore, if in my test program above, I comment out error and get(), then my debugging print statements show that type->alias.exported is set for foo. Weird!

Hopefully someone with a bit more familiarity with the codebase might be able to solve this faster than I can.

~smlavine 2 years ago

brocc in #hare said today that this code works on commit fcb4b5f. I tested this and it is true. One git-bisect later, I've identifed the bad commit as 8fcadc2. This helps to narrow down the scope of the problem a bit.

~turminal REPORTED FIXED 2 years ago

Fixed in 7d1f4cf5f3b34969dda64eeec345c1f21e58967b

Register here or Log in to comment, or comment via email.