Skip to content

Commit

Permalink
Error properly when trying to peek into an array as a scalar.
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jul 4, 2010
1 parent 0c50088 commit ac39bd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/Partcl/Actions.pm
Expand Up @@ -192,7 +192,16 @@ method variable:sym<normal>($/) {
make PAST::Op.new( :pasttype<unless>,
PAST::Op.new( :pirop<isnull>, $variable),
$variable,
PAST::Op.new( :pasttype<unless>,
PAST::Op.new( :pirop<iseq__iss>,
PAST::Op.new( :pirop<typeof__sP>, $variable),
PAST::Val.new( :value<TclArray>)
),
$variable,
PAST::Op.new( :pasttype<call>, :name<error>,
"can't read \"$<identifier>\": variable is array"
)
),
PAST::Op.new( :pasttype<call>, :name<error>,
"can't read \"$<identifier>\": no such variable"
)
Expand Down
8 changes: 4 additions & 4 deletions t/tcl_var_subst.t
@@ -1,7 +1,7 @@
# Copyright (C) 2004-2007, The Parrot Foundation.

source lib/test_more.tcl
plan 20
plan 20; # + 2 skips

eval_is {
catch {unset a}
Expand Down Expand Up @@ -43,7 +43,7 @@ eval_is {
catch {unset a}
set a(b) 2
set b $a
} {can't read "a": variable is array} {try to use array as scalar} {TODO NQPRX}
} {can't read "a": variable is array} {try to use array as scalar}

eval_is {
catch {unset x}
Expand Down Expand Up @@ -90,14 +90,14 @@ eval_is {
catch {unset foo}
array set foo {$ ok}
set b $foo($)
} ok {single $ as index} {TODO NQPRX}
} ok {single $ as index}

eval_is {
catch {unset foo}
array set foo {) ok}
set key )
set b $foo([set key])
} ok {use ) as a key} {TODO NQPRX}
} ok {use ) as a key}

eval_is {
catch {unset array}
Expand Down

0 comments on commit ac39bd4

Please sign in to comment.