Skip to content

Commit

Permalink
make assignment type check errors more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Feb 19, 2011
1 parent 2fc617f commit 14319fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/ChangeLog
@@ -1,3 +1,6 @@
New in 2011.03 release
+ improved error message on type check failure in assignment

New in 2011.02 release
+ IPv6 support
+ more robust numeric exponentation
Expand Down
14 changes: 13 additions & 1 deletion src/builtins/assign.pir
Expand Up @@ -13,6 +13,8 @@ src/builtins/assign.pir - assignment operations
.param pmc cont
.param pmc source

.annotate 'invizible_frame', 1

cont_loop:
# If the lhs isn't marked rw, throw exception
.local pmc rw
Expand Down Expand Up @@ -40,7 +42,15 @@ src/builtins/assign.pir - assignment operations
if null type goto type_ok
$P0 = type.'ACCEPTS'(source)
if $P0 goto type_ok
'&die'('Type check failed for assignment')
.local string error_msg
error_msg = "Type check failed for assignment\n Container type: "
$S0 = type.'perl'()
error_msg = concat error_msg, $S0
error_msg = concat error_msg, "\n Got: "
$P0 = source.'WHAT'()
$S0 = $P0.'perl'()
error_msg = concat error_msg, $S0
'&die'(error_msg)
type_ok:

# Dereference the scalar LHS. If the thing we're
Expand Down Expand Up @@ -82,6 +92,8 @@ src/builtins/assign.pir - assignment operations

cont_store:
.tailcall cont.'!STORE'(source)

.annotate 'invizible_frame', 1
.end


Expand Down

0 comments on commit 14319fc

Please sign in to comment.