fix: Ignore declarations used by code snippets that will never end up in the WGSL code

Đang mở
#3,203 1 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 2 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
45/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
computer-graphics

Hướng nghiên cứu

The reproduction is a test that calls tgpu.resolve([fn]) and checks the output with toMatchInlineSnapshot; run it first and compare the generated WGSL against the snapshot. The issue is that helper is emitted even though its only use sits in a branch that never reaches the output. Find where the resolver collects dependent declarations and where it decides which ones to emit. Done means helper is omitted in that case and the snapshot is updated.

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

Mô tả

[!NOTE]
This might not be worth the effort

This is not super urgent, it's mostly a cosmetic issue, but we might be able to (in rare cases) reduce the amount of code we generate.

test('...', ({ root }) => {
  const helper = () => {
    'use gpu';
    return 0;
  };
  const fn = () => {
    'use gpu';
    if (std.typeOf(helper()) === d.i32) {
      return 1;
    } else {
      return 0;
    }
  };

  expect(tgpu.resolve([fn])).toMatchInlineSnapshot(`
    "fn helper() -> i32 {
      return 0;
    }

    fn fn_1() -> i32 {
      return 1;
    }"
  `);
});
Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
141
Merge trung bình
3 ngày 7 giờ
Pull request đã merge (30 ngày)
66

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

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 software-mansion/TypeGPU

Tất cả issue của software-mansion/TypeGPU

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.