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

[core/bash_impl] Use error_code_t to return error #2175

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

akinomyoga
Copy link
Collaborator

@akinomyoga akinomyoga commented Dec 6, 2024

#2167 (comment)

Also I think it would be nice to have

if error == bash_impl.IndexOutOfRange

instead of hard-coding 1 . Then we don't need the comment, and it is more readable

This introduces an enum type to return the error status of a negative out-of-bound index of indexed arrays. To add the enum, I added error_code = OK | IndexOutOfRange in runtime.asdl (which may be extended to include other types of errors in the future). If there is a better way, please let me know.

@andychu
Copy link
Contributor

andychu commented Dec 6, 2024

This looks great, thank you! ASDL is nice to use like this

Given what I wrote in:

#2168

I think eventually we will have

OK | BadNegativeIndex | BadPositiveIndex

because bash happens to behave differently in these cases.

But I guess we can do that when we get to it

@andychu andychu changed the base branch from master to soil-staging December 6, 2024 16:32
@andychu andychu merged commit 21afe25 into soil-staging Dec 6, 2024
18 checks passed
@akinomyoga akinomyoga deleted the runtime_asdl.error_code_t branch December 6, 2024 16:45
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