Skip to content

Commit

Permalink
Error When Using Invalid Column With add-col!
Browse files Browse the repository at this point in the history
Return an error when `add-col!` is called with an invalid column.
  • Loading branch information
cwarden committed Aug 2, 2024
1 parent 8b70a4f commit 46e7916
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion evaldo/builtins_spreadsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ func GenerateColumn(ps *env.ProgramState, s env.Spreadsheet, name env.Word, extr
}
// fmt.Println(val)
if er != nil {
return nil
return MakeBuiltinError(ps, er.Error(), "add-col!")
}
if firstVal == nil {
var ok bool
Expand Down
7 changes: 7 additions & 0 deletions tests/structures.rye
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ section "Spreadsheet related functions"
equal { to-spreadsheet vals { dict { "a" 1 b 2 "c" 3 } dict { "a" 4 "b" 5 } } } spreadsheet { "a" "b" "c" } { 1 2 3 4 5 _ }
}

group "add-col"
mold\nowrap ?add-col!
{ { block } }
{
equal { try { spreadsheet { "n" } [ 1 ] |add-col! 'm { x } { x } } |type? } 'error
}

group "index"
mold\nowrap ?add-indexes!
{ { block } }
Expand Down

0 comments on commit 46e7916

Please sign in to comment.