Commit 2ab383c9

2ab383c94a2dMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified

Description

fix(codegen): poly body return unboxes to const char * when return is String

Issue #655: an RBS-declared -> String method whose body returns a poly (sp_RbVal) ternary -- typical when @hash[key] || "" is the body and the hash inferred to value-type Int because no writes were observed -- emitted return <sp_RbVal_expr> from a function signature of const char *, tripping C compile.

compile_body_return_inner adds a poly -> string / mutable_str arm that unboxes via .v.s before return. Mirror the existing poly -> bigint unbox arm (#651-family).

This is the local-rewrite fix surface mentioned in the issue. The deeper RBS-driven hash-value inference (so the @hash value type follows the RBS return rather than defaulting to Int) would be a separate, larger pass.

Closes #655.

Default 633/0/0 (+1 regression test). Optcarrot wrap checksum 59662 unchanged.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
2ab383c94a2d
Parent
cfb183194d96

.gitignoremodifiedView file

@@ -33,3 +33,4 @@
3333 # Local Claude config
3434 .claude/
3535 CLAUDE.local.md
36+file_write_poly_arg