Tcl Source Code

View Ticket
Login
Ticket UUID: 1574835
Title: wrong#args problem in [apply] guts
Type: Bug Version: obsolete: 8.5a5
Submitter: dkf Created on: 2006-10-10 21:35:17
Subsystem: 22. [proc] and [uplevel] Assigned To: msofer
Priority: 8 Severity:
Status: Closed Last Modified: 2006-10-25 06:13:09
Resolution: Fixed Closed By: msofer
    Closed on: 2006-10-24 23:13:09
Description:
% namespace ensemble create -command bar -map {id
{const foo}}
::bar
% proc const val { return $val }
% proc alias {object slot = command args} {
     set map [namespace ensemble configure $object -map]
     dict set map $slot [linsert $args 0 $command]
     namespace ensemble configure $object -map $map
 }
% proc method {object name params body} {
     set params [linsert $params 0 self]
     alias $object $name = ::apply [list $params $body
::] $object
 }
% method bar boo x {return "[expr {$x*$x}] - $self"}
% bar ?
unknown or ambiguous subcommand "?": must be boo, or id
% bar boo
wrong # args: should be "bar boo"

That's a wrong error message, should be:
  wrong # args: should be "bar boo x"
User Comments: msofer added on 2006-10-25 06:13:09:
Logged In: YES 
user_id=148712

Added apply-4.3-5

msofer added on 2006-10-24 07:37:15:
Logged In: YES 
user_id=148712

Fixed in HEAD, tests missing.

msofer added on 2006-10-24 05:53:52:
Logged In: YES 
user_id=148712

Patch in [Bug 1577492] has been committed, this patch should
be adapted so that [interp alias] benefits too.

msofer added on 2006-10-15 10:03:44:
Logged In: YES 
user_id=148712

See also [Bug 1577492] for a solution to the [info level]
problem.

dgp added on 2006-10-12 21:03:35:
Logged In: YES 
user_id=80530


Looks like you're re-opening
the issues from 217806,
218638, 218015.

The *really* important issue
in those reports got corrected,
but the incompat in [info level]
data remained.

msofer added on 2006-10-12 08:44:20:
Logged In: YES 
user_id=148712

To illustrate that the problem is at least partially with
[info level]:

% proc foo {} {info level 0}
% alias bar boo = foo
% bar boo
::foo

msofer added on 2006-10-12 08:39:11:

File Added - 197791: 1574835.diff

Logged In: YES 
user_id=148712

Attached a patch that fixes this particular issue, but
raises some others. It uses ns-ensemble's machinery.

New test failures:

apply-4.1,2: Tcl_WrongNumArgs is quoting where it shouldn't. 

---- Result was:
1 {wrong # args: should be "apply {{x {set x 1}}} x"}
---- Result should have been (exact matching):
1 {wrong # args: should be "apply {x {set x 1}} x"}


Apply-6.2,3: [info level] does not know about ensemble
rewriting. I think it should.

    set lambda [list args {info level 0}]
    apply $lambda x y
---- Result was:
{args {info level 0}} x y
---- Result should have been (exact matching):
apply {args {info level 0}} x y

msofer added on 2006-10-11 05:34:02:
Logged In: YES 
user_id=148712

Oohh ... nasty, the error messages for curried lambdas are
not quite ok.

% set lam [list {self x} {return "[expr {$x*$x}] - $self"}]
{self x} {return "[expr {$x*$x}] - $self"}
% apply $lam bar
wrong # args: should be "apply {{self x} {return "[expr
{$x*$x}] - $self"}} self x"
% interp alias {} try {} apply $lam bar
try
% try
wrong # args: should be "apply {{self x} {return "[expr
{$x*$x}] - $self"}} self x"

That should be instead:
wrong # args: should be "try x"

Or should it?
% interp alias {} try2 {} boo bar
try2
% try2
wrong # args: should be "boo self x"
[Side note: should interp alias rewrite the error message
ust like ensemble aliases? Probably ...]


There is here (I think) some interplay between ::apply
returning such a funny error message (with a two-word
command name, plenty of spaces in there too) and the
ensemble's rewriting rules.

Attachments: