forked from AbleOS/holey-bytes
forgot to support explicit enum type
This commit is contained in:
parent
12b9d43754
commit
e079bbd312
|
@ -2877,6 +2877,32 @@ impl<'a> Codegen<'a> {
|
|||
};
|
||||
}
|
||||
|
||||
if let ty::Kind::Enum(e) = tty.expand() {
|
||||
let intrnd = self.tys.names.project(name);
|
||||
let Some(index) =
|
||||
self.tys.enum_fields(e).iter().position(|f| Some(f.name) == intrnd)
|
||||
else {
|
||||
let field_list = self
|
||||
.tys
|
||||
.enum_fields(e)
|
||||
.iter()
|
||||
.map(|f| self.tys.names.ident_str(f.name))
|
||||
.intersperse("', '")
|
||||
.collect::<String>();
|
||||
self.report(
|
||||
pos,
|
||||
fa!(
|
||||
"the '{}' does not have this variant, \
|
||||
but it does have '{field_list}'",
|
||||
self.ty_display(tty)
|
||||
),
|
||||
);
|
||||
return Value::NEVER;
|
||||
};
|
||||
|
||||
return Some(self.ci.nodes.new_const_lit(tty, index as i64));
|
||||
}
|
||||
|
||||
let ty::Kind::Struct(s) = self.tys.base_of(tty).unwrap_or(tty).expand() else {
|
||||
self.report(
|
||||
pos,
|
||||
|
|
Loading…
Reference in a new issue