Skip to content

Make exact and non-exact heap types the same case - #106

Merged
tlively merged 6 commits into
mainfrom
exact-heaptype-refactor
Jul 24, 2026
Merged

Make exact and non-exact heap types the same case#106
tlively merged 6 commits into
mainfrom
exact-heaptype-refactor

Conversation

@tlively

@tlively tlively commented Jul 13, 2026

Copy link
Copy Markdown
Member

Previously the definition of heaptype was ... | EXACT typeuse | typeuse, but this made it impossible to treat the exactness as a variable. Refactor the definition to ... | _HT exact? typeuse instead. This is similar to how nullability is treated in reference types, except that the _HT tag will not be displayed in the rendered spec.

Previously the definition of `heaptype` was `... | EXACT typeuse | typeuse`, but this made it impossible to treat the exactness as a variable. Refactor the definition to `... | _HT exact? typeuse` instead. This is similar to how nullability is treated in reference types, except that the `_HT` tag will not be displayed in the rendered spec.
@tlively
tlively requested a review from rossberg July 13, 2026 11:53
@tlively

tlively commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

The only problem with this is that non-exact references now render with extra parentheses, e.g. (ref null (x)). @rossberg, do you know how to fix that?

@tlively

tlively commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

I figured out the parentheses. This should be good to go.

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right, parens are suppressed around element sequences whose first elements are hidden atoms.

The hack to suppress rendering of parens in other cases is to abuse double escape parens for grouping, i.e., write $($(...)) instead of (...).


rule Heaptype_ok/exact:
C |- EXACT typeuse : OK
C |- _HT exact? typeuse : OK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use the keyword directly in rules where there's no need to name it (e.g., because it is co-iterated multiple times).

Suggested change
C |- _HT exact? typeuse : OK
C |- _HT EXACT? typeuse : OK

Comment on lines +166 to +168
def $unrollht(C, _HT exact? deftype) = $unrolldt(deftype)
def $unrollht(C, _HT exact? _IDX typeidx) = $unrolldt(C.TYPES[typeidx])
def $unrollht(C, _HT exact? REC i) = C.RECS[i]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def $unrollht(C, _HT exact? deftype) = $unrolldt(deftype)
def $unrollht(C, _HT exact? _IDX typeidx) = $unrolldt(C.TYPES[typeidx])
def $unrollht(C, _HT exact? REC i) = C.RECS[i]
def $unrollht(C, _HT EXACT? deftype) = $unrolldt(deftype)
def $unrollht(C, _HT EXACT? _IDX typeidx) = $unrolldt(C.TYPES[typeidx])
def $unrollht(C, _HT EXACT? REC i) = C.RECS[i]

rule Heaptype_sub/exact-l:
C |- EXACT typeuse <: heaptype
-- Heaptype_sub: C |- typeuse <: heaptype
C |- _HT exact typeuse <: heaptype

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
C |- _HT exact typeuse <: heaptype
C |- _HT EXACT typeuse <: heaptype

@tlively
tlively merged commit cded4e0 into main Jul 24, 2026
12 of 13 checks passed
@tlively
tlively deleted the exact-heaptype-refactor branch July 24, 2026 18:31
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