Skip to content

Refactoring Field Error Function into one Function #2336

@MahadMuhammad

Description

@MahadMuhammad

Refactoring Field Error Function

Both the lines you modified have the exact same error message and pattern. I think it would be worth opening an issue to factor them into one function (emit_invalid_field_error or w/ever) in this file, and it's something you can work on if you like. This will make it easier for you to rework the Error emitting code once we get to that point in your GSoC project @MahadMuhammad

Originally posted by @CohenArthur in #2326 (comment)

if (!variant->lookup_field (ident.get_identifier (), &field,
nullptr))
{
rust_error_at (ident.get_locus (), ErrorCode ("E0026"),
"variant %s does not have a field named %s",
variant->get_identifier ().c_str (),
ident.get_identifier ().c_str ());
break;
}

if (!variant->lookup_field (ident.get_identifier (), &field,
nullptr))
{
rust_error_at (ident.get_locus (), ErrorCode ("E0026"),
"variant %s does not have a field named %s",
variant->get_identifier ().c_str (),
ident.get_identifier ().c_str ());
break;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions