Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[question?] counterintuitive class method behaviour

Open
#21,670 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Quiet
Domain
documentation

Research direction

Start with the CodeQL query and output shown in the issue, then read the documentation covering class methods and predicate evaluation. Confirm the intended behavior and identify the relevant documentation section; done means the behavior is explained clearly enough to address the reported mental-model gap.

Written by the indexing model from the issue text.

Description

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?)

Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 16h
Merged PRs (30d)
143

Contributor guide

Open the contributing guide

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

All issues in github/codeql

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.