gleam-lang/gleam

Qualified constants cannot be referenced inside bit array size segment patterns.

开放

#5,607 创建于 2026年4月11日

 (1 条评论) (0 个反应) (0 位负责人)Rust (960 个派生)batch import
good first issuehelp wanted

仓库指标

星标
 (21,417 个星标)
PR 合并指标
 (平均合并 10天 19小时) (30 天内合并 69 个 PR)

描述

When pattern matching on a bit array, the compiler produces a syntax error if a qualified imported constant is referenced inside a size segment, for example:

import example/internal

const lap_data_size = 50

pub fn parse(bits:BitArray)->Result(_,Nil){
  case bits {
    <<
      lap_data:bytes-size(internal.maximum_cars * lap_data_size),
      time_trial_personal_best_car:unsigned-int-8,
      time_trial_rival_car:unsigned-int-8,
    >> -> todo
    _ -> todo
  }
}

This code produces the following error pointing to internal.:

Syntax error

I was not expecting this.

Found `.`, expected one of: 
- `)`

贡献者指南