Skip to content
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

compiletime array of bindSym - Internal Compiler Error #11668

Closed
mratsim opened this issue Jul 5, 2019 · 2 comments
Closed

compiletime array of bindSym - Internal Compiler Error #11668

mratsim opened this issue Jul 5, 2019 · 2 comments
Labels
Macros VM see also `const` label

Comments

@mratsim
Copy link
Collaborator

mratsim commented Jul 5, 2019

This might be related to #10628

The following case 1 will trigger an ICE. Replacing bindSym by ident will not trigger it (case 2), or wrapping it in another array works (case 3).

import macros

type
  SimdPrimitives* = enum
    simdSetZero
    simdBroadcast
    simdAdd

template noop*(scalar: untyped): untyped =
  scalar

template unreachable*(): untyped =
  {.error: "Unreachable".}

# #################################
# Case 1 - Internal Compiler Error
# Error: internal error: (filename: "seminst.nim", line: 328, column: 17)

let genericPrimitives{.compileTime.}: array[SimdPrimitives, NimNode] = [
  simdSetZero:   bindSym"unreachable",
  simdBroadcast: bindSym"noop",
  simdAdd:       bindSym"+",
]

# #################################
# Case 2 - Compiles

# let genericPrimitives{.compileTime.}: array[SimdPrimitives, NimNode] = [
#   simdSetZero:   ident"unreachable",
#   simdBroadcast: ident"noop",
#   simdAdd:       ident"+",
# ]

# #################################
# Case 3 - SubArray - Compiles

# type
#   SimdArch* = enum
#     archGeneric
#     x86_SSE

# proc genSimdTableX86(): array[SimdArch, array[SimdPrimitives, NimNode]] =

#   let genericPrimitives: array[SimdPrimitives, NimNode] = [
#     simdSetZero:   bindSym"unreachable",
#     simdBroadcast: bindSym"noop",
#     simdAdd:       bindSym"+",
#   ]

#   result =[
#     archGeneric: genericPrimitives,
#     x86_SSE: default(array[SimdPrimitives, NimNode])
#   ]

# let SimdTable*{.compileTime.} = genSimdTableX86()
@mratsim mratsim added Compiler Crash Macros VM see also `const` label labels Jul 5, 2019
@metagn
Copy link
Collaborator

metagn commented Aug 29, 2024

No longer crashes but gives a ambiguous identifier: + error

@mratsim
Copy link
Collaborator Author

mratsim commented Sep 25, 2024

Then I think it's solved. + matches with many so I would need a local + that binds stronger to help the compiler.

@mratsim mratsim closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Macros VM see also `const` label
Projects
None yet
Development

No branches or pull requests

2 participants