Skip to content

Vector types spec - #1195

Open
Kronos3 wants to merge 6 commits into
feature/vector-typesfrom
vector-types-spec
Open

Kronos3 wants to merge 6 commits into
feature/vector-typesfrom
vector-types-spec

Conversation

@Kronos3

@Kronos3 Kronos3 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Spec for #1057

There is some overlap with the spec work done for range-types having to do with "fallible" value conversion after type checking passes. I've synced up with the latest spec we merged into feature/range-types which should make the inevitable merge conflict less painful.

@Kronos3
Kronos3 requested a review from bocchino November 17, 2026 15:45
@Kronos3

Kronos3 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

After review with @bocchino, the following actions have been raised:

  • Change syntax to vector V = [] U32 size 4: FwSizeType
  • Follow Rob’s type+value conversion pattern from range-types-semantics branch
  • Rename "size-prefix type" -> "length representation type"
  • 22.8 - 2 array type T and size n
  • For type conversion, enumerate each rule case:
    • AA -> V -> ok if E convertible & len(AA) <= size(V)
    • V -> AA -> ok if E convertible
    • V -> V -> ok if E convertible
  • 23.2.8 vector type, v1 has k element -> vector type and v1 has k elements

stem:[T_2]
and stem:[T_2] may be converted to stem:[T_3], then stem:[T_1]
may be converted to stem:[T_3].
The one exception is that a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't have an exception to transitivity here. Let's discuss the motivation for this and address the underlying cause. I expect it's a workaround for a defect elsewhere in the rules.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the exception to transitivity. Convert V to [V]

array type stem:[T_2] if stem:[T_1] may be converted to the member type of
stem:[T_2].

. An anonymous array type stem:[T_1 =] _[_ stem:[n] _]_ stem:[T'_1]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these conversion rules are too permissive, because with transitivity, you can use them to convert [n] T to [m] T for any n and m, by going through a vector of T.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever need to convert a vector type to an anonymous array type? If not, we could disallow that conversion.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided we should disallow this

Comment thread docs/spec/Type-Checking.adoc Resolved

This branch has not been deployed

No deployments
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