[question?] counterintuitive class method behaviour
- Linguagem predominante
- CodeQL
- Estrelas
- 10.1k
- Forks
- 2.1k
- Merge médio
- 2d 15h
- PRs com merge (30d)
- 141
Descrição
When I write a query like this:
```codeql
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?)
Guia de contribuição
Direção de pesquisa
Comece pela consulta e pela saída do CodeQL mostradas na issue e, em seguida, leia a documentação que aborda métodos de classe e avaliação de predicados. Confirme o comportamento pretendido e identifique a seção relevante da documentação; considera-se concluído quando o comportamento estiver explicado com clareza suficiente para abordar a lacuna relatada no modelo mental.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100