[question?] counterintuitive class method behaviour

Đang mở
#21,670 9 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với truy vấn và đầu ra CodeQL được hiển thị trong issue, sau đó đọc tài liệu về các phương thức của lớp và việc đánh giá predicate. Xác nhận hành vi dự kiến và xác định phần tài liệu liên quan; được xem là hoàn tất khi hành vi được giải thích đủ rõ để giải quyết khoảng trống trong mô hình tư duy đã được báo cáo.

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

Mô tả

question

When I write a query like this:

class Meow extends Struct {
  Field f;
  Meow() {
    f.getDeclaringType() = this
  }
  Field getField() { result = f }
}

from Meow m
select m, m.getField(), m.getField()

My mental model of this is: "Meow is essentially a (struct, struct's field) tuple. from Meow m will select all of those tuples. For each of those , select m, m.getField(), m.getField() will print their contents."

But that is actually not what happens, because you get results like this:

|                 m                 |                        col1                         |                        col2                         |
+-----------------------------------+-----------------------------------------------------+-----------------------------------------------------+
// [snip]
| port_io_ops                       | f_inb                                               | f_outb                                              |
// [snip]

Which means that the first m.getField() and the second m.getField() are operating on different Meow objects.

I've been debugging a bug in my query for hours now only to realize that this is what happens. Is this really intended? I read through a non-trivial amount of documentation and did not realize this, I feel like my whole mental model of how codeql works is shattering :S

(If it is really intended, could the documentation be updated to point this out more clearly?)

Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 11 giờ
Pull request đã merge (30 ngày)
129

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 github/codeql

Tất cả issue của github/codeql

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.