Skip to content

return error on non-string element in join#969

Open
netliomax25-code wants to merge 2 commits into
expr-lang:masterfrom
netliomax25-code:join-string-assert
Open

return error on non-string element in join#969
netliomax25-code wants to merge 2 commits into
expr-lang:masterfrom
netliomax25-code:join-string-assert

Conversation

@netliomax25-code
Copy link
Copy Markdown

join([1,2]) hits arg.(string) on the []any branch and surfaces a raw "interface conversion: interface {} is int, not string" runtime error instead of the invalid argument for join error the other branches return. Check the assertion and return that error.

Comment thread builtin/builtin.go
default:
v := reflect.ValueOf(args[0])
if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
return nil, 0, fmt.Errorf("cannot sort %s", v.Kind())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this is from another pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants