Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: 3383e3f7c92f3d5883f90cadf67da2d16b5fa6a3
Ticket: 35fdc88036489d43b4dd1b326527dc0bd7762bf7
proc: disallow duplicated parameter names in arg spec
User & Date: mr_calvin 2017-02-23 12:52:19
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    % proc foo {a a a} {return [concat [info local] $a]}; foo 1 2 3
    a a a 1
    
    To quote KBK from IRC yesterday :)
    
    "Arguably, that's a bug. It surely doesn't do anything useful, and we probably should detect it as an error."
    
    "The fact that Tcl has been around for 27 years, and nobody's noticed [proc x {a a a} { ... }] until now indicates that it's low-worry, especially if it doesn't cause a crash. (I expect that it'll just discard the first two args at run time.)"
    
    Low-worry, indeed, but potentially irritating ([info]) and kind of puzzling after so many years.
    
    In the attached patch, I gave it a shot. Tests were added to proc.test, two tests fixed in trace.test (actually using repeated names!). The above one liner will now result in a proper TCL_ERROR:
    
    arg list contains a duplicate entry "a"
    
    Stefan
    
  5. foundin changed to: "8.7a0"
  6. is_private changed to: "0"
  7. login: "mr_calvin"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "d4d1d8192a46acf2c7d58cddc1040ecdbc9c9d77"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "mr_calvin"
  14. subsystem changed to: "22. [proc] and [uplevel]"
  15. title changed to:
    proc: disallow duplicated parameter names in arg spec
    
  16. type changed to: "Patch"