From ac39bd49149d9a397c31b576a2175eb3c957aed6 Mon Sep 17 00:00:00 2001 From: Coke Date: Sun, 4 Jul 2010 14:37:42 -0400 Subject: [PATCH] Error properly when trying to peek into an array as a scalar. --- src/Partcl/Actions.pm | 11 ++++++++++- t/tcl_var_subst.t | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Partcl/Actions.pm b/src/Partcl/Actions.pm index fa6315a..7bdf608 100644 --- a/src/Partcl/Actions.pm +++ b/src/Partcl/Actions.pm @@ -192,7 +192,16 @@ method variable:sym($/) { make PAST::Op.new( :pasttype, PAST::Op.new( :pirop, $variable), - $variable, + PAST::Op.new( :pasttype, + PAST::Op.new( :pirop, + PAST::Op.new( :pirop, $variable), + PAST::Val.new( :value) + ), + $variable, + PAST::Op.new( :pasttype, :name, + "can't read \"$\": variable is array" + ) + ), PAST::Op.new( :pasttype, :name, "can't read \"$\": no such variable" ) diff --git a/t/tcl_var_subst.t b/t/tcl_var_subst.t index f24ba88..2926296 100755 --- a/t/tcl_var_subst.t +++ b/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} @@ -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} @@ -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}