Repository navigation
Conversation
Tcl's == tries a numeric comparison first, so "1e3" == "1000" and "0x10" == "16" are true. Every ==/!= whose operand is a string (a literal such as "NULL", "POWER", "BLOCK", "WC", or a variable holding a name, type or extension) becomes eq/ne; a list is tested with llength. Numeric comparisons are left alone. Adds the rule to TclContract.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Øyvind Harboe <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request standardizes Tcl string comparisons across the flow scripts by replacing the equality operators '==' and '!=' with the more appropriate 'eq' and 'ne' operators. A review comment correctly identified that a temporary file, 'flow/abc.history', was accidentally included in the commit and should be removed. Additionally, the reviewer provided actionable feedback suggesting more idiomatic Tcl patterns for checking variable existence and string emptiness, which improve the maintainability and readability of the updated scripts.
I am having trouble creating individual review comments. Click here to see my feedback.
flow/abc.history (1-23)
This file (abc.history) appears to be a temporary run file/history file generated by Yosys/ABC during execution. It should not be committed to the repository. Please remove it from the pull request and ensure it is ignored (e.g., by adding it to .gitignore if not already present).
flow/scripts/macro_place_util.tcl (1)
Since find_macros returns a string (constructed via append macros " " $inst in util.tcl), checking if it is non-empty using ne "" is more direct and idiomatic than converting it to a list with llength. This also aligns with the PR's goal of using string comparison operators.
if { [find_macros] ne "" } {
flow/util/cell-veneer/lefdef.tcl (108)
In Tcl, info exists is the standard and most efficient way to check if a variable exists. Using [info vars antennamodel] ne "" is a roundabout way of doing this and is less idiomatic.
if { [info exists antennamodel] } {
flow/util/cell-veneer/lefdef.tcl (122)
In Tcl, ![info exists antennamodel] is the standard and most efficient way to check if a variable does not exist. Using [info vars antennamodel] eq "" is less idiomatic.
if { ![info exists antennamodel] } {
flow/util/cell-veneer/lefdef.tcl (133)
In Tcl, ![info exists antennamodel] is the standard and most efficient way to check if a variable does not exist. Using [info vars antennamodel] eq "" is less idiomatic.
if { ![info exists antennamodel] } {
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Øyvind Harboe <[email protected]>
|
Gemini review, checked against the code:
|
🔍 QoR checkMetrics reflect the PR merge build — i.e. what will land on the target branch. Commit 62 design(s) checked — 0 with regression(s), 0 without a comparable baseline. ✅ QoR is compared against the master build at this PR's merge base |
An environment variable is a string even when it holds a list, so the sibling PRs that read optional lists from the environment test them with ne ""; the rule now says which test goes with which value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Øyvind Harboe <[email protected]>
Strings are compared with
eq/ne, not==/!=.Tcl's
==tries a numeric comparison first:"1e3" == "1000"and"0x10" == "16"are true. A name, type or extension that happens to look like a number would compare equal to another. This changes every==/!=inflow/scripts,flow/platformsandflow/utilwhose operand is a string ("NULL","POWER","GROUND","BLOCK","WC","BC",".v","6_final", a layer direction, ...) toeq/ne.$lib_cells == {}tests a list, so it becomes an[llength ...]check. Numeric comparisons (RECOVER_POWER != 0,getId, resistances, coordinates,[llength $x] == 0,catchcodes) are left alone. The rule is added todocs/contrib/TclContract.md.Why: code that is easier to read (the operator says what the operands are), failures that are hard and early rather than a string quietly passing as a number, and fewer squirrels for an AI reading the scripts to chase: a
==that turns strings into numbers is one of them.env_var_equals(util.tcl) is not touched here; it is owned by #4911.Behaviour
Unchanged for every real value. Evidence: full flow (
make finish, synth through report) onmastervs this branch, normalised logs and every stage metric JSON diffed. 0 log differences, 0 metric differences on:KEEP_VARS=1)gf180/setRC.tclmacro_place_util.tcl(Only failure in every arm, before and after alike: the final GDS merge, as the klayout Python module is not installed here.)
flow/util/cell-veneer/*is not run by the flow; checked bytclint/tclfmt0.9.0 only.🤖 Generated with Claude Code