Cross-file as const array import resolves as unknown

Open
#264 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
compilers

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
113
Forks
13
Avg merge
15h 35m
Merged PRs (30d)
56

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from midspiral/LemmaScript

All issues in midspiral/LemmaScript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.