Skip to content

Commit

Permalink
oo.tcl: fix error in defaultconstructor
Browse files Browse the repository at this point in the history
$classname is not accessible, so use [info level 0]

Fixes #248

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed Jan 5, 2023
1 parent 08a2ad8 commit 2f7be1c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions oo.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ proc class {classname {baseclasses {}} classvars} {
lindex [split $p " "] 1
}]
}
# Pre-defined some instance methods
# Pre-define some instance methods
$classname method defaultconstructor {{__vars {}}} {
set __classvars [$self classvars]
foreach __v [dict keys $__vars] {
if {![dict exists $__classvars $__v]} {
return -code error "$classname, $__v is not a class variable"
# level 3 because defaultconstructor is called by new
return -code error -level 3 "[lindex [info level 0] 0], $__v is not a class variable"
}
set $__v [dict get $__vars $__v]
}
Expand Down

0 comments on commit 2f7be1c

Please sign in to comment.