diff options
author | Jake Leahy <jake@leahy.dev> | 2023-08-04 20:21:36 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 12:21:36 +0200 |
commit | 3efabd3ec669914ad2bb42a614f7277caf662562 (patch) | |
tree | 9bc143868fd06481bd2c385d1557ac3c270bc2cc /tests/generics | |
parent | 7c2a2c8dc810a837b93ee0e8bcaf6d8969f5a54a (diff) | |
download | Nim-3efabd3ec669914ad2bb42a614f7277caf662562.tar.gz |
Fix crash when using uninstantiated generic (#22379)
* Add test case * Add in a bounds check when accessing generic types Removes idnex out of bounds exception when comparing a generic that isn't fully instantiated
Diffstat (limited to 'tests/generics')
-rw-r--r-- | tests/generics/tuninstantiated_failure.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/generics/tuninstantiated_failure.nim b/tests/generics/tuninstantiated_failure.nim new file mode 100644 index 000000000..f09b115d6 --- /dev/null +++ b/tests/generics/tuninstantiated_failure.nim @@ -0,0 +1,16 @@ +discard """ +cmd: "nim check $file" +""" + +type + Test[T, K] = object + name: string + Something = Test[int] + +func `[]`[T, K](x: var Test[T, K], idx: int): var Test[T, K] = + x + +var b: Something +# Should give a type-mismatch since Something isn't a valid Test +b[0].name = "Test" #[tt.Error + ^ type mismatch]# |