8000 vine: object type equality checking allows omission of fields · Issue #197 · VineLang/vine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vine: object type equality checking allows omission of fields #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nilscrm opened this issue Mar 19, 2025 · 2 comments · May be fixed by #212
Open

vine: object type equality checking allows omission of fields #197

nilscrm opened this issue Mar 19, 2025 · 2 comments · May be fixed by #212

Comments

@nilscrm
Copy link
Contributor
nilscrm commented Mar 19, 2025

Vine does not check that destructing an object uses an exhaustive pattern matching, i.e. some fields can be missing, even in situation where this shouldn't be the case. This usually leads to crashes/non-termination in the IVM.

Minimal example:

pub fn main(&io: &IO) {
  let Foo({a}) = Foo({a: 1, b: 2});
  io.println("{a}");
}

struct Foo {
  a: N32,
  b: N32,
}
@nilscrm
Copy link
Contributor Author
nilscrm commented Apr 22, 2025

Just realized this also applies to constructions. This means the compiler won't complain about the following which can again lead to run-time crashes:

struct Foo {
  a: N32,
  b: N32,
}

pub fn main(&io: &IO) {
  let foo = Foo({a: 0});
}

@tjjfvi
Copy link
Member
tjjfvi commented Apr 22, 2025

Yeah, it's a general issue with the type equality checking for objects.

@tjjfvi tjjfvi changed the title Partial object pattern allowed where only exhaustive pattern is valid vine: object type equality checking allows omission of fields Apr 23, 2025
@tjjfvi tjjfvi linked a pull request Apr 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0