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

ICE when assigning non-gen value to (valid) array access of gen #64

Open
pbeart opened this issue Feb 12, 2025 · 1 comment
Open

ICE when assigning non-gen value to (valid) array access of gen #64

pbeart opened this issue Feb 12, 2025 · 1 comment
Labels
bug Something isn't working ICE Internal Compiler Error

Comments

@pbeart
Copy link
Collaborator

pbeart commented Feb 12, 2025

E.g. this works:

gen int[2] p
gen int q = p[0]

so does this:

int[2] p
int q = p[0]

but this gives an ICE:

gen int[2] p
int q = p[0]

The error is:

thread 'main' panicked at src\value.rs:55:44:
internal error: entered unreachable code
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\panicking.rs:665
   1: core::panicking::panic_fmt
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/core\src\panicking.rs:76
   2: core::panicking::panic
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/core\src\panicking.rs:148
   3: enum2$<sus_compiler::value::Value>::get_type_best_effort
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\value.rs:55
   4: sus_compiler::instantiation::InstantiationContext::alloc_wire_for_const
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\execute.rs:507
   5: sus_compiler::instantiation::InstantiationContext::get_wire_or_constant_as_wire
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\execute.rs:528
   6: sus_compiler::instantiation::InstantiationContext::instantiate_connection
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\execute.rs:379
   7: sus_compiler::instantiation::InstantiationContext::instantiate_code_block
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\execute.rs:766
   8: sus_compiler::instantiation::InstantiationContext::execute_module
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\execute.rs:908
   9: sus_compiler::instantiation::perform_instantiation
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\mod.rs:405
  10: sus_compiler::instantiation::InstantiationCache::instantiate
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\instantiation\mod.rs:240
  11: sus_compiler::linker::Linker::recompile_all
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\compiler_top.rs:239
  12: sus_compiler::linker::Linker::update_text
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\dev_aid\lsp\mod.rs:84
  13: sus_compiler::dev_aid::lsp::lsp_main
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\dev_aid\lsp\mod.rs:633
  14: sus_compiler::main
             at C:\Users\verya\Projects\sus_clean\sus-compiler\src\main.rs:49

Also worth noting that if the index is out of bounds, no ICE occurs (e.g. the following code does not trigger a ICE despite following the same pattern of non-gen variable using array access of a gen variable)

gen int[2] p
int q = p[3]
@pbeart pbeart added the bug Something isn't working label Feb 12, 2025
@VonTum VonTum added the ICE Internal Compiler Error label Feb 14, 2025
@pbeart pbeart changed the title CSE when assigning non-gen value to (valid) array access of gen ICE when assigning non-gen value to (valid) array access of gen Feb 17, 2025
@pbeart
Copy link
Collaborator Author

pbeart commented Feb 17, 2025

More information: this also occurs when assigning an array to the value of a gen array, correctly sized or not, i.e. all of the following cause ICE:

gen int[3] a
gen int[3] b = a
gen int[3] a
gen int[2] b = a
gen int[3] a
int[2] b = a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ICE Internal Compiler Error
Projects
None yet
Development

No branches or pull requests

2 participants