---
title: "Check the language version before you accept an idiom comment | Proofline"
description: "An idiom comment is a claim about language semantics, so check it against the specification for the version your build uses."
url: https://proofline.sh/learn/ai-review-language-idiom-comment/
---

[Learning center](/learn/)

# Check the language version before you accept an idiom comment

An idiom comment is a claim about language semantics, so check it against the specification for the version your build uses. That version is set by the go line in go.mod, requires-python, or the compiler or runtime target. Change the code when the hazard exists in that version and this code reaches it. Dismiss the comment, citing the version and the specification, when the version removed the hazard or the code never reaches it.

Code review The Proofline team November 22, 2026 5 min read

## Why idiom claims go stale

Much of the code reviewers learned from predates the current language. Go changed two loop rules in version 1.22. The specification now says "Each iteration has its own separate declared variable (or variables)", and a `for` statement with a `range` clause "may iterate over integer values from zero to an upper limit." [Go specification, Go 1.22 changes](https://go.dev/ref/spec#Go_1.22) Advice written for earlier versions, such as copying a loop variable before capturing it, is still correct for modules that declare an older version and redundant for the rest.

What matters is the version the compiler applies, which in Go comes from the `go` line of the module's `go.mod`. I built the same file under two `go.mod` versions with Go 1.24.7:

```
rewardCount := 3
for j := range rewardCount {
	fmt.Print(j, " ")
}
```

With `go 1.21` the build fails: "cannot range over rewardCount (variable of type int): requires go1.22 or later (-lang was set to go1.21; check go.mod)". With `go 1.24` it prints `0 1 2`. A closure that captures `i` from a three-iteration `for i := 0; i < 3; i++` loop prints `3 3 3` under `go 1.21` and `0 1 2` under `go 1.22`.

## A claim that was wrong for the module's version

In April 2025, a cleanup pull request in the Nibiru blockchain repository converted several counted loops to range-over-int loops. CodeRabbit flagged them as invalid: "Identical issue as above: `range rewardCount` is illegal because `rewardCount` is an `int`, not a slice." It proposed restoring `for j := 0; j < rewardCount; j++`. [Review](https://github.com/SaiDotFun/nibiru/pull/2298#pullrequestreview-2785168734)

The claim was true before Go 1.22 and false for this module, whose `go.mod` at the merge commit declares `go 1.24`. The pull request merged on 23 April 2025 with the range loop in place; the merged `eth/rpc/backend/chain_info.go` still reads `for j := range rewardCount {`. The files view shows a resolved thread on that file, and GitHub hides the text of resolved threads, so I could not read any reply. The build settles it: at this language version the range compiles and yields 0 to `rewardCount - 1`, the same values as the loop the bot wanted back.

## A claim that was redundant but cheap to satisfy

In November 2026, automated review checks on a TykTechnologies/ai-studio pull request reported a loop variable captured by a goroutine in `NewPostgresPair`. The checks' own wording was not visible on the page I read; the author's summary of it was. The author explained in the thread why it was "not a bug on this module's Go version": "`go.mod` declares `go 1.26.5`, and since Go 1.22 each iteration of a `for` loop has its own copy of the loop variable," "so the two goroutines see `i = 0` and `i = 1`." [Author's comment](https://github.com/TykTechnologies/ai-studio/pull/953#issuecomment-6781752737)

The `go.mod` at the merge commit does declare `go 1.26.5`, and no nested module covers that package. The author then changed the code anyway: "both changes were made anyway, to clear the checks." The goroutine "now takes the index as an argument (behaviour unchanged, for the reason given above)." [Follow-up comment](https://github.com/TykTechnologies/ai-studio/pull/953#issuecomment-6781781655)

When the change is free and a check blocks the merge, that is reasonable, provided the reply records that the finding was wrong for this version, as this one did. Nobody later reads the change as a bug fix.

## Check the claim for your version

| Claim | What decides it | Change when | Dismiss when |
| --- | --- | --- | --- |
| Go loop variable captured by a closure or goroutine | The `go` line in the module's `go.mod`; per the specification, Go 1.22 gave each iteration its own variable | The module declares a version before 1.22 | The module declares 1.22 or later |
| Go `range` over an integer is invalid | The same `go` line | The module declares a version before 1.22 | The module declares 1.22 or later |
| Python mutable default argument | Whether the function mutates the default or returns it to callers | The default is appended to, updated or returned | The default is only read |
| JavaScript `==` should be `===` | The operand, and the project's ESLint `eqeqeq` setting | The comparison involves values where coercion changes the result, such as `0`, `""` or `false` | The comparison is `x == null`, deliberately matching `null` and `undefined`, and the configuration allows it |

The Python rule is in the language reference: "Default parameter values are evaluated from left to right when the function definition is executed," so "the same “pre-computed” value is used for each call." [Python reference: function definitions](https://docs.python.org/3/reference/compound_stmts.html#function-definitions) A function that appends to a default list shares that list across calls; in my run, after two calls the two results both printed as `['a', 'b']`, because they are the same list. A function that only iterates over its default `[]` returned an empty list whenever it used the default, so a comment about it is a style preference.

For JavaScript, `x == null` is true for `null` and `undefined` and false for `0`, `""` and `false`, which I confirmed in Node 22. ESLint's `eqeqeq` rule has a `"smart"` option that allows "Comparing against `null`", and an `"always"` option that takes `{"null": "ignore"}` for the same purpose. [ESLint eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq) If your configuration already permits the idiom, the comment repeats a decision the project made, which [findings already covered by lint](/learn/review-findings-already-covered-by-lint/) treats separately.

## Reply with the version

A dismissal of an idiom comment needs three facts: the version the build uses, where that version is set, and a link to the rule. For example: "`go.mod` declares `go 1.24`; range over int is valid from Go 1.22 (spec link)." If the reviewer accepts instructions, put the language versions in them, as described in [writing custom review rules](/learn/write-custom-ai-code-review-rules/), and rerun it on the same commit to confirm the claim no longer appears.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which review findings does your linter already cover?](/learn/review-findings-already-covered-by-lint/)
    
    Code review The Proofline team November 20, 2026 3 min read
    
-   ### [How to write custom AI code review rules for a repository](/learn/write-custom-ai-code-review-rules/)
    
    Code review The Proofline team November 18, 2026 3 min read
