Odin icon indicating copy to clipboard operation
Odin copied to clipboard

creating a parametric struct with mismatched parameter count

Open awwdev opened this issue 3 years ago • 1 comments

Odin dev-2021-09:b3dc3f59

Foo :: struct($A: typeid) {}
foo: Foo(int, f32, 123, rawptr, nil, ODIN_DEBUG) //mismatch
fmt.println(foo)

should be a syntax error, but the compiler does not report an error instead compilation stalls and never finishes

awwdev avatar Sep 21 '21 08:09 awwdev

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]

Still a problem in dev-2022-12:1d6f7680. Please reopen.

awwdev avatar Dec 25 '22 17:12 awwdev

I'm submitting a PR which I believe fixes this and related issues.

The following code reproduces a variety of errors if too many parameters are passed to a polymorphic record type:

package main

main :: proc() {
    Foo :: struct($A: typeid) {}

    bar: Foo(i32, 1, 1, 1, 1) = {};
    // stalls and never finishes with odin built debug

    // bar: Foo(int, 1, 1, 1, 1, 1)
    // munmap_chunk(): invalid pointer

    // bar: Foo(int, f32, 1, 1, rawptr, ODIN_DEBUG)
    // free(): invalid pointer

    // bar: Foo(A = int, A = int);
    // src/array.cpp(61): Assertion Failure: `cast(usize)index < cast(usize)count` Index 1 is out of bounds ranges 0..<1

    // ^ IMPORTANT: you may need to move the uncommented line above the other commented out lines
    // to get the exact error.
}

Note that these problems were reproduced using a debug version of odin. A release build may act somewhat differently but it still won't work.

See the PR for details of the fix.

rick-masters avatar Mar 13 '24 00:03 rick-masters