From b26fd1f6d21bbebafb1dc48216a50e0c3d098f11 Mon Sep 17 00:00:00 2001 From: Ed J Date: Tue, 17 Dec 2024 13:30:47 +0000 Subject: [PATCH] clearer error when get PP index wrong --- lib/PDL/PP/PdlParObj.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PDL/PP/PdlParObj.pm b/lib/PDL/PP/PdlParObj.pm index 7523000ac..31691f664 100644 --- a/lib/PDL/PP/PdlParObj.pm +++ b/lib/PDL/PP/PdlParObj.pm @@ -217,10 +217,12 @@ sub do_indterm { my($this,$pdl,$ind,$subst,$context) = @_; my $index = delete($subst->{$substname}) // # No => get the one from the nearest context. (grep $_ eq $substname, map $_->[1], reverse @$context)[0]; - croak "pp_def($this->{Sig}{OpName}): Access Index not found: $pdl, $ind, @{[$this->{IndObjs}[$ind]->name]} - On stack:".(join ' ',map {"($_->[0],$_->[1])"} @$context)."\n" - if !defined $index; - return "(".($this->get_incname($ind,1))."*($index))"; + if (!defined $index) { + croak "pp_def($this->{Sig}{OpName}): no value given for ndarray '$pdl' index '$substname' + You supplied (@{[sort keys %$subst]}) + On stack: ".(join ' ',map {"($_->[0],$_->[1])"} @$context)."\n" + } + "(".($this->get_incname($ind,1))."*($index))"; } sub get_xsdatapdecl {