Skip to content

Support shorthand ivar string interpolation - #22

Merged
joeldrapper merged 1 commit into
yippee-fun:mainfrom
willcosgrove:embedded-variable
Jan 8, 2026
Merged

joeldrapper merged 1 commit into
yippee-fun:mainfrom
willcosgrove:embedded-variable

Conversation

@willcosgrove

Copy link
Copy Markdown
Contributor

Currently strict_ivars will produce incorrect code if it encounters an embedded variable node:

"#@foo"

will become

"#(defined?(@foo) ? @foo : (::Kernel.raise(::StrictIvars::NameError.new(self, :@foo))))"
# ^ no { so no interpolation

Here's the situation where I noticed this was happening:
CleanShot 2026-01-05 at 14 56 30@2x

I added test cases, and a visitor for the EmbeddedVariableNode. I also added an early return if the variable is already in context. But it's not strictly required, it just seemed like a nice thing to do 🤷‍♂️

@joeldrapper joeldrapper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great. We need to copy this into empirical too.

@joeldrapper
joeldrapper merged commit 16f04a3 into yippee-fun:main Jan 8, 2026
9 checks passed
@willcosgrove
willcosgrove deleted the embedded-variable branch January 8, 2026 22:10
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