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

BUG: unhandled primitive in codegen: slice_literal #14572

Closed
BlobCodes opened this issue May 7, 2024 · 0 comments · Fixed by #15009
Closed

BUG: unhandled primitive in codegen: slice_literal #14572

BlobCodes opened this issue May 7, 2024 · 0 comments · Fixed by #15009
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen

Comments

@BlobCodes
Copy link
Contributor

Bug Report

The following code results in a compiler bug:

a = Slice(UInt8).literal(0)
b = Slice(UInt8).literal(1)

This only happens when both variables are not constants (or if there is no assignment at all) and if both literals have the same amount of elements.
This also doesn't happen if the two literals have different types (ex. Slice(UInt32) and Slice(UInt8)).

Stack trace:

BUG: unhandled primitive in codegen: slice_literal (Exception)
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'codegen_assign'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/enumerable.cr:510:7 in '??'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2362:7 in 'codegen'
  from /crystal/src/compiler/crystal/compiler.cr:202:16 in 'compile:combine_rpath'
  from /crystal/src/compiler/crystal/compiler.cr:195:56 in 'compile:combine_rpath'
  from /crystal/src/compiler/crystal/command/eval.cr:30:5 in 'eval'
  from /crystal/src/compiler/crystal/command.cr:126:12 in 'run'
  from /crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from /crystal/src/crystal/main.cr:129:5 in 'main'
  from src/env/__libc_start_main.c:95:2 in 'libc_start_main_stage2'

⬢[blob@toolbox ~]$ crystal -v
Crystal 1.12.1 [4cea10199] (2024-04-11)

LLVM: 15.0.7
Default target: x86_64-unknown-linux-gnu

⬢[blob@toolbox ~]$ crystal env
CRYSTAL_CACHE_DIR=/var/home/blob/.cache/crystal
CRYSTAL_PATH=lib:/usr/share/crystal/src
CRYSTAL_VERSION=1.12.1
CRYSTAL_LIBRARY_PATH=/usr/lib64/crystal
CRYSTAL_LIBRARY_RPATH=''
CRYSTAL_OPTS=''
@BlobCodes BlobCodes added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants