I was trying to set value in gdb, I have:
(gdb) set j=4
(gdb) set i=5
Ambiguous set command "i=5": .
(gdb) set ::i=6
(gdb) set variable i=6
Your example is:
(gdb) set i=5 Ambiguous set command "i=5": .
This is not a name lookup error but rather the consequence of how gdb parses commands. (That trailing
: . looks like it ought to mean something, or list something; but it just seems odd.)
set can be used to evaluate an expression, as you discovered with
set j = 4 -- but this only happens because there is no gdb command starting with
set tries any matching subcommands first, recognizing abbreviations. And since there are multiple commands starting
set i (such as
set input-radix, ...), gdb doesn't know which to choose. So, it complains that the command is ambiguous.
The real command to set a variable is
set variable, which is why the final try worked.
Note that other commands taking an expression can also evaluate an assignment. I tend to use
set variable just because it is shorter.