Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a runtime error when trying to slice an unsupported type #442

Merged
merged 1 commit into from
Feb 24, 2024
Merged

Throw a runtime error when trying to slice an unsupported type #442

merged 1 commit into from
Feb 24, 2024

Conversation

mkuznets
Copy link
Contributor

Add a missing switch case corresponding to a slice of an unsupported type. Without it Tengo continues execution past the unsupported slice with an invalid stack state, causing unexpected behaviour or obscure errors.

Example:

test := func() {
    a := 42
    return undefined[:5]
}

fmt := import("fmt")
fmt.println(test())  // -> prints 42

This PR changes it to throw a runtime error instead, which is consistent with similar cases such as using a function call operator on an unsupported type.

Copy link
Collaborator

@geseq geseq left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. LGTM.

@geseq geseq merged commit 9d35005 into d5:master Feb 24, 2024
1 check passed
@mkuznets mkuznets deleted the mkuznets/not-indexable branch February 24, 2024 13:21
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