-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Summary
Currently, T-Ruby's inline object type literal ({ field: Type }) support is inconsistent across different contexts. This issue tracks the work to improve and unify this support.
Current Status
| Context | Status | Example |
|---|---|---|
| Function parameters | ✅ Supported | def foo(config: { host: String, port: Integer }) |
| Interface members | ✅ Supported | interface Config { settings: { debug: Boolean } } |
| Class fields | @info: { name: String, age: Integer } |
|
| Variable declarations | ❌ Not supported | config: { host: String } = { ... } |
Technical Details
Root Cause
The parse_typed_assignment() method in token_declaration_parser.rb:458 only accepts :constant tokens in the type position, preventing hash literal types from being parsed in variable declarations.
Affected Files
lib/t_ruby/parser_combinator/token/token_declaration_parser.rblib/t_ruby/ir.rb(HashLiteralType class at line 682)
Proposed Improvements
- Variable Declarations: Extend
parse_typed_assignment()to callparse_type()instead of only accepting:constanttokens - Class Fields: Add tests and documentation for
@field: { ... }syntax - Documentation: Update docs to clarify where inline object type literals are supported
Related
- TypeScript equivalent: Object Type Literal / Anonymous Object Type
- IR class:
TRuby::IR::HashLiteralType
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Backlog