~sircmpwn/hare#889: 
Improve slice/array type representation in the compiler

It's counterintuitive as hell and a constant source of bugs:

  • At the unchecked ast level, slices and arrays both use struct ast_list_type with confusing rules about which combination of field values means what.
  • At the checked level, both use a struct confusingly named struct type_array again, meanings of field value combinations are confusing. Additionally, the struct has a field bool expandable, which actually is used in quite a lot of places. I don't think that should be a part of the checked type.

The actual state of things is that arrays come with 3 special kinds, unbounded, expandable and contextual. Expandability is a property of the array expression, not the type. (Un)boundedness is a property of the type, expressions of unbounded array types can't even exist. Contextuality is a property of the type, but depending on how we're going to implement it in the end, it may be relevant to the expession as well. Whatever representation will replace the current one, those special cases need to be stored in the right places, and stored explicitly.

The representation used for slice types should be separate, and simpler.

Status
REPORTED
Submitter
~turminal
Assigned to
No-one
Submitted
1 year, 2 months ago
Updated
7 months ago
Labels
harec spec stdlib

~sebsite 1 year, 2 months ago

We should also make these same changes in hare::parse.

Expandability is a property of the array expression, not the type.

This currently isn't true. Making it a property of the expression is probably the correct thing to do, but the spec will need to be updated.

Contextuality is a property of the type, but depending on how we're going to implement it in the end, it may be relevant to the expression as well.

Related: #886. We should probably figure that out first before we make any changes here.

~turminal 7 months ago

Bor Grošelj Simić referenced this ticket in commit 42573fc.

~turminal 7 months ago

Bor Grošelj Simić referenced this ticket in commit c0db5b1.

Register here or Log in to comment, or comment via email.