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

chore: Add secondary message for UnknownLoopBound error #4268

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

vezenovm
Copy link
Contributor

@vezenovm vezenovm commented Feb 5, 2024

Description

Problem*

Resolves #3687

Summary*

This simply adds a secondary message to clarify that using a slice length will lead to the Could not determine loop bound at compile-time error.

I was thinking of disabling this earlier during type check but we don't necessarily know that we will have a slice until codegen as arrays and slices are polymorphic with one another. I also thought about making a separate runtime error to check during loop unrolling but we are not necessarily going to still have the ArrayLen call codegen'd in SSA and will instead have the call's results for the loop condition, so this isn't a basic check and some more logic would be needed.

The best option for a specific error check seems to be during codegen_for before we codegen the end range. We can check whether we are making a slice ArrayLen call for the end range. These changes all felt a bit much as the error is quite clear except for this one error case and thus a secondary message felt sufficient.

If we would like the error to be more specific for the failure case then I can look at adding logic that triggers an error for a slice length loop bound.

An example of the error now:
Screenshot 2024-02-05 at 5 10 39 PM

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@vezenovm vezenovm requested a review from jfecher February 5, 2024 22:11
@TomAFrench TomAFrench added this pull request to the merge queue Feb 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2024
@TomAFrench TomAFrench added this pull request to the merge queue Feb 6, 2024
Merged via the queue into master with commit f466fa1 Feb 6, 2024
35 checks passed
@TomAFrench TomAFrench deleted the mv/expand-slice-len-bound-err branch February 6, 2024 01:36
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.

Sha512 cannot hash slices
2 participants