Skip to content

Support braceless shape types in T::Struct fields - #647

Merged
Morriar merged 1 commit into
support-top-level-sig-bindfrom
support-tstruct-shape-types
Aug 5, 2026
Merged

Support braceless shape types in T::Struct fields#647
Morriar merged 1 commit into
support-top-level-sig-bindfrom
support-tstruct-shape-types

Conversation

@Morriar

@Morriar Morriar commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Depends on #645.

Add support for braceless hash-rocket shape types in T::Struct fields:

class Configuration < T::Struct
  const :settings, "timeout" => Integer
  prop :options, :enabled => T::Boolean
end

The parser now restores the braces required to represent these values unambiguously as types:

class Configuration < T::Struct
  const :settings, {"timeout" => Integer}
  prop :options, {:enabled => T::Boolean}
end
  • support string, symbol, mixed, and multiple shape keys in const and prop
  • move shared shape normalization into Parser::Visitor
  • reuse the same normalization for returns, top-level bind, and T::Struct fields
  • preserve keyword argument syntax such as prop :options, enabled: T::Boolean rather than treating it as a shape
  • translate normalized fields into valid RBS attribute and constructor types

@Morriar
Morriar merged commit 57bae18 into support-top-level-sig-bind Aug 5, 2026
8 checks passed
@Morriar
Morriar deleted the support-tstruct-shape-types branch August 5, 2026 13:22
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