Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 897933be16b5c616b75f44ebfa902393ccbacc56261c6dc937447d19a52d1ffd
Ticket: beecfca5fd9316c55b82e0e15d995d82bcfaee09
Tcl_ParseArgsObjv unhelpful error message
User & Date: emiliano on 2025-04-21 13:11:39
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    The function Tcl_ParseArgsObjv() behaves differently depending on whether the last argument, remObjv, is null or not. In the case of null last argument, it errors out when parses an unrecognized argument. The error message, however, is not on par with other functions like Tcl_GetIndexFromObj(). For example:
    
    C side table:
    
        const Tcl_ArgvInfo argsTable[] = {
            {TCL_ARGV_STRING,  "-command",    NULL     , &command,    NULL, NULL},
            {TCL_ARGV_GENFUNC, "-flush",      ParseBool, &flush  ,    NULL, NULL},
            {TCL_ARGV_STRING,  "-variable",   NULL,      &variable,   NULL, NULL},
            {TCL_ARGV_GENFUNC, "-watchunset", ParseBool, &watchunset, NULL, NULL},
            TCL_ARGV_TABLE_END
        };
    
    Tcl result:
    
    % parseargs -foo asd
    unrecognized argument "-foo"
    %
    
    Compare, for example, with other standard error messages
    
    % lsort -foo {}
    bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -indices, -integer, -nocase, -real, -stride, or -unique
    % 
    
    Since Tcl_ParseArgsObjv() already provides a way to print a helpful error message with TCL_ARGS_AUTO_HELP (or the corresponding full entry with TCL_ARGV_HELP type), I think it would be better to add this information after the terse 'unrecognized argument "-foo"' error message.
    
    The attached patch implements such change, resulting instead in
    
    % parsewithout -foo asd
    unrecognized argument "-foo"
    Command-specific options:
     -command:    
     -flush:      
     -variable:   
     -watchunset: 
    %
    
    Note that when remObjv option is not null the function doesn't error out on unrecognized options, copying them out to remObjv instead.
    
  5. foundin changed to: "9.0"
  6. is_private changed to: "0"
  7. login: "emiliano"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "emiliano"
  13. subsystem changed to: "- New Builtin Commands"
  14. title changed to: "Tcl_ParseArgsObjv unhelpful error message"
  15. type changed to: "RFE"