crystal-lang / crystal

The Crystal Programming Language

Home Page:https://crystal-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG: unhandled primitive in codegen: slice_literal

BlobCodes opened this issue · comments

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=''