You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More specifically, the index must be an integer, whether a constant, variable or expression. In Go, this would be float64(int(i)) == i where i is the index.
Error on non-integer index and slice expressions as it doesn't make much sense
to use it, e.g. in arr[1.1]. We are reusing the nice error message wording
that was introduced in with the ErrBadRepetion. We have also copied the way
we do normalizeSlices indices from evaluator, basing it on normalizeIndex.
Fixes#317
Error on non-integer index and slice expressions as it doesn't make much sense
to use it, e.g. in arr[1.1]. We are reusing the nice error message wording
that was introduced in with the ErrBadRepetion.
Fixes#317
Error on non-integer index and slice expressions as it doesn't make much sense
to use it, e.g. in arr[1.1]. We are reusing the nice error message wording
that was introduced in with the ErrBadRepetion. We have also copied the way
we do normalizeSlices indices from evaluator, basing it on normalizeIndex.
Fixes#317
This merges the following commits:
* bytecode: Refactor slice and index normalization
* eval: Error on non-integer index and slice expressions
pkg/bytecode/value.go | 78 ++++++++++++++++++++-------------
pkg/bytecode/vm_test.go | 29 ++++++++++++
pkg/evaluator/evaluator.go | 1 +
pkg/evaluator/evaluator_test.go | 5 ++-
pkg/evaluator/value.go | 4 ++
5 files changed, 85 insertions(+), 32 deletions(-)
Pull-request: #331
This should cause a runtime error.
More specifically, the index must be an integer, whether a constant, variable or expression. In Go, this would be
float64(int(i)) == i
wherei
is the index.Currently, the value is truncated via conversion to
int
: https://github.com/evylang/evy/blob/main/pkg/evaluator/value.go#L374The text was updated successfully, but these errors were encountered: