Skip to content

Struct initializers allow missing fields #3892

Closed

Description

@brson
struct BuildData {
    foo: int,
    bar: ~int
}

fn main() {
    let foo = BuildData {
        foo: 0
    };

    debug!("%?", foo.bar);
}

This will crash

Activity

  1. brson commented on Oct 31, 2012

    @brson
    ContributorAuthor

    There is code for this in check_struct_or_variant_fields that doesn't seem to be working. There aren't tests.

  2. ghost assigned on Oct 31, 2012
  3. brson commented on Oct 31, 2012

    @brson
    ContributorAuthor

    This is more or less the same bug as #3486, different manifestations.

  4. added a commit that references this issue on Sep 17, 2024
  5. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions