Skip to content

Conversation

@tiif
Copy link
Member

@tiif tiif commented Oct 28, 2025

No description provided.

// FIXME: we only support const in value expression of tuple for now, we can add support
// more in future.
let Constant(_) = value_expression else {
bail!("Only Constant is supported in ValueExpression::Struct for now.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bail!("Only Constant is supported in ValueExpression::Struct for now.")
bail!("Only Constant is supported in ValueExpression::Tuple for now.")

Comment on lines -288 to -305
let Some(adt_id) = ty.get_adt_id() else {
bail!("The local used for field projection is not adt.")
};

let (
_,
AdtDeclBoundData {
where_clause: _,
variants,
},
) = self.decls.adt_decl(&adt_id).binder.open();
let AdtDeclVariant { name, fields } = variants.last().unwrap();

if *name != VariantId::for_struct() {
bail!("The local used for field projection must be struct.")
if !ty.is_tuple() && !ty.is_adt() {
bail!("The local used for field projection must be ADT or Tuple")
}

// Check if the index is valid for the tuple.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, While tuple (i32, u32)'s parameter is [i32, u32],

struct Foo<T> {
    value: T
}

struct Foo's parameter is T.

But I don't like how we need to go through self.decls to get the struct field information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants