Menu

#45 False postive with fully qualified command names

1.0
open
nobody
None
Bug
2023-09-24
2023-09-20
Tobias Mark
No

This code

    proc cmd {a} {}
        namespace eval main {
            proc cmd {} {}
            proc foo {} {
                ::cmd a
                cmd
            }
        }

generates an error:

Line   5: E Wrong number of arguments (1) to "main::cmd"

But is perfectly legal.
With a quick look in the code I can't see where to begin. The arguments for lookForCommand are already missing the "::" prefix.

(This neither caused nor fixed by my recent pull request #16)

Discussion

  • Tobias Mark

    Tobias Mark - 2023-09-20

    Looks like this is a regression caused by commit 73aeb9166e75e33cd50bd4fd6d1c0c4a729458d2

     
  • Peter Spjuth

    Peter Spjuth - 2023-09-24

    The main problem is the removal of :: in parseStatement, which makes it impossible to distinguish the call to "::cmd" and "cmd" downstream in the code. I do not recall why it was added in 73aeb.
    But it all boils down to that the code mostly assumes "cmd" is global and that namespaces has been added later and not in a very good way.
    I think the namespace resolution needs to be moved to early in parseStatement, but it is not obvious at a glance how.

     

Log in to post a comment.

MongoDB Logo MongoDB