-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Internal Error with with static generic parameters #1082
Comments
linagl/vector can be seen here: https://gist.github.com/BitPuffin/10470877#file-vector-nim-L1 |
The error above has been fixed with Araq's latest static[T] fixes. However, there's now an internal compiler error. Here's compileable code: import math
type
TMatrix*[T; R, C: static[int]] = array[0..R-1, array[0..C-1, T]] ## Row major matrix type.
TMat4* = TMatrix[float32, 4, 4]
TVector*[T; C: static[int]] = array[0..C-1, T]
TVec4* = TVector[float32, 4]
template row*[T; R, C: static[int]](m: TMatrix[T, R, C], rowidx: range[0..R-1]): TVector[T, R] =
m[rowidx]
proc col*[T; R, C: static[int]](m: TMatrix[T, R, C], colidx: range[0..C-1]): TVector[T, C] {.noSideEffect.} =
for i in low(m)..high(m):
result[i] = m[i][colidx]
proc `*`*[T; R, N, C: static[int]](a: TMatrix[T, R, N], b: TMatrix[T, N, C]): TMatrix[T, R, C] {.noSideEffect.} =
for i in low(a)..high(a):
for j in low(a[i])..high(a[i]):
result[i][j] = a.row(i) * b.col(j)
proc translate*(v: TVec4): TMat4 {.noSideEffect.} =
result = [[1f32, 0f32, 0f32, 0f32],
[0f32, 1f32, 0f32, 0f32],
[0f32, 0f32, 1f32, 0f32],
[v[0], v[1], v[2], 1f32]]
proc rotatex*(angle: float): TMat4 =
result = [[1f32, 0f32, 0f32, 0f32],
[0f32, cos(angle).float32, sin(angle).float32, 0f32],
[0f32, -sin(angle).float32, cos(angle).float32, 0f32],
[0f32, 0f32, 0f32, 1f32]]
proc orbitxAround(point: TVec4, angle: float): TMat4 =
result = translate(point)*rotatex(angle)*translate(point) Throws:
|
Clyybber
pushed a commit
to Clyybber/Nim
that referenced
this issue
Feb 24, 2024
## Summary Clean up the category and enable it for all targets by default. This significantly increases test coverage of exceptions for the JS and VM targets. ## Details **General changes/cleanup:** * references to issues like `nim-lang#1234` are replaced with proper GitHub links * the `targets` key is removed for tests that should be run on all targets * usage of `cmd` is replaced with usage of `matrix` (allowing for multi-target testing) * `write(stdout, ...)` is replaced with `echo` in order to support the JS and VM targets * execution of `static:` blocks is replaced with using the VM target, when the test is not specific to compile-time execution * tests that don't work but should are marked as `knownIssue` **Specific changes:** * where not necessary for the test, `getCurrentExceptionMsg` is replaced with `getCurrentException().msg`, as the former is not yet supported by the VM * `texceptions2.nim` is removed -- it's redundant with `texception.nim` * `texception_message_null_byte.nim` is turned into a normal test that doesn't rely on self-execution
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import linagl/vector
Error:
It appears that it doesn't know ho to map the R and C of TMat4 to TMatrix. The instantiation is in orbitxAround
The text was updated successfully, but these errors were encountered: