PDE doesn't report invalid size() arguments as a logic error

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

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
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
compilers

Hướng nghiên cứu

Start with the Java Mode preprocessing and the existing sizeParamValid() handling described in the issue. Run the Java test suite and inspect the added regression-test cases for invalid method and variable arguments. Done means invalid size(width, height) in setup() is reported as a PDE logic error, while settings() and arithmetic expressions remain valid.

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

Mô tả

bug
Most appropriate sub-area of Processing 4?

PDE

Processing version

4.5.6

Operating system

Windows

Bug description

When size() is called from setup() using variables for its width and height, Processing reports the error only when the sketch is run/compiled:

size() cannot be used here, see https://processing.org/reference/size_.html

However, the PDE does not report this as a logic error while editing the sketch.

This is inconsistent with other invalid size() usage and makes the problem harder to identify before running the sketch.

For comparison, using the same variables from settings() works correctly, and arithmetic expressions such as size(400 + 400, 900 - 300) are accepted.

Expected behavior

The PDE should identify the invalid size() usage as a logic error while editing, before the sketch is run.

Actual behavior

The invalid usage is not reported as a PDE logic error while editing. The error is encountered when the sketch is processed/run.

Steps to reproduce this
  1. Open Processing 4.
  2. Create a new Java Mode sketch.
  3. Add the following code:
  4. Wait for the PDE to process the sketch.
  5. Observe that the invalid size() usage is not reported as a logic error in the editor.
  6. Run the sketch.
  7. Processing reports:

size() cannot be used here, see https://processing.org/reference/size_.html

For comparison, moving the size(width, height) call into settings() allows the sketch to run successfully.

snippet
int width = 800;
int height = 600;

void setup() {
  size(width, height);
}
Additional context

The issue appears to originate in the Java Mode preprocessing of size() arguments.

I investigated the existing sizeParamValid() handling and implemented a change that reports invalid size() arguments as a logic error during preprocessing. I also added regression tests for invalid method and variable arguments.

I manually verified the following cases:

  • size(width, height) in setup() → logic error
  • size(width, height) in settings() → works
  • size(400 + 400, 900 - 300) → works

The Java test suite passes with 194 tests and 0 failures on my local setup.

I would be interested in working on this issue and submitting the corresponding fix.

Would you like to work on the issue?

Yes, I’d like to help with this

Ngôn ngữ chính
Java
Star
497
Fork
183
Merge trung bình
4 giờ 39 phút
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 processing/processing4

Tất cả issue của processing/processing4

Issue tương tự

Thêm issue về Java

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.