Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Strings] Make string a subtype of ext, not any #7373

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

kripken
Copy link
Member

@kripken kripken commented Mar 13, 2025

StringLowering converts strings to externs, which makes sense as we lower
stringrefs to imported JS strings. For the reverse transform it is convenient
to just have strings be subtypes of ext, see #7370 - that makes it simple to
switch stringref to externref and vice versa.

@kripken kripken requested a review from tlively March 13, 2025 23:51
Comment on lines +449 to +451
// Bottom types already handled (including string as the switch value,
// which implies the other value is bottom, which again would have been
// handled).
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the addition to this comment. string isn't a bottom type, so why is it included in the bottom types already having been handled?

@@ -949,8 +956,9 @@ std::optional<HeapType> HeapType::getSuperType() const {
case none:
case exn:
case noexn:
case string:
Copy link
Member

Choose a reason for hiding this comment

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

Yikes! This doesn't look like it was correct before, since it should have returned any. Do you know how this wasn't caught by tests?

Comment on lines -491 to -493
(any.convert_extern
(extern.convert_any
(string.const "string")
Copy link
Member

Choose a reason for hiding this comment

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

It might still be useful to test any.convert_extern of a string.

Comment on lines +239 to +240
(ref.null noextern) ;; The change from stringref to externref does not
;; cause problems here, nothing needs to change.
Copy link
Member

Choose a reason for hiding this comment

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

Does this unlock any potential code simplifications in StringLowering.cpp?

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