Repository navigation
fix(compiler): index and slice type parameters that can be strings - #554
Merged
Merged
Conversation
Indexing or slicing a value whose type is a type parameter with a string in its type set, such as T ~string | ~[]byte, used the slice helpers, which panicked with "index on unsupported type" when the value was a string. This is how github.com/clipperhouse/uax29/v2/graphemes reads its data, which Cogent Code reaches at startup. Such values now use the indexStringOrBytes and sliceStringOrBytes helpers, as strings do. Signed-off-by: Randall C. O'Reilly <randall@astera.org>
Member
|
Merged through dev so this PR retains its merged status, then landed on master as 96c8245 with the original author preserved. The amendment corrects three stale runtime tests: Go print spacing and clone methods for two registered struct fixtures. It also adds a purpose comment in the constraint inspection. The generic string/byte compliance test passes from a clean archive without generated drift. All 76 tests in the three affected runtime files, TypeScript checking, the compiler and CLI build, and repository lint pass. Source review found no remaining defect; the independent review route was unavailable because its usage allowance was exhausted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Indexing or slicing a value whose type is a type parameter with a string in its type set, such as
T ~string | ~[]byte, used the slice helpers (arrayIndex,goSlice), which panic with "runtime error: index on unsupported type" when the value is a string. github.com/clipperhouse/uax29/v2/graphemes reads its data this way inIterator.Next, so Cogent Code crashed on startup. Such values now use the existingindexStringOrBytesandsliceStringOrByteshelpers, as strings do.The new compliance test generic_string_bytes_index indexes and slices strings, byte slices and a named string type through such type parameters, and fails without the change.
go test ./compilerpasses.