Cross-file as const array import resolves as unknown

Đang mở
#264 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
compilers

Hướng nghiên cứu

Start by tracing how imported declarations from a.ts are resolved and how readonly tuples are converted for Dafny emission; inspect the tuple homogeneity rule and the diagnostic for unsupported .includes() calls. Reproduce with the issue’s a.ts and b.verify.ts example using lsc check --backend=dafny. Done means the readonly tuple resolves to seq<string> and emits successfully, or the tool reports a clear diagnostic that as const is unsupported.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

A cross-file as const array import loses its element type and arrives as unknown, so every method call on it fails emission:

a.ts:

export const methods = ["get", "post", "put"] as const;

b.verify.ts:

//@ backend dafny
import { methods } from "./a.js";
export function isKnown(m: string): boolean {
//@ verify
  return methods.includes(m);
}

Evidence

  • Before: lsc check --backend=dafny fails with ERROR: Dafny emission failed for 'isKnown' in b.verify.ts: Unsupported Dafny method call: .includes() on unknown. Exit 1.
  • After (expected): the readonly tuple resolves to seq<string> like a plain array literal does (see the tuple homogeneity rule), or a clear diagnostic names as const as unsupported.

Merge Danger

Door: two-way — emission failure, fails loud.

Blast radius: toolchain — shared constant tables (as const is the idiomatic way to define them) are unusable across files.

Ngôn ngữ chính
TypeScript
Star
113
Fork
13
Merge trung bình
16 giờ 22 phút
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của midspiral/LemmaScript

Tất cả issue của midspiral/LemmaScript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.