Skip to content

checker: fix stack var outside usage when var is a mutable param#24249

Merged
medvednikov merged 3 commits into
vlang:masterfrom
felipensp:fix_checker_stack_var
Apr 20, 2025
Merged

checker: fix stack var outside usage when var is a mutable param#24249
medvednikov merged 3 commits into
vlang:masterfrom
felipensp:fix_checker_stack_var

Conversation

@felipensp

Copy link
Copy Markdown
Member

Fix #24179

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22630

Comment thread vlib/v/checker/checker.v
is_mut_param := c.table.cur_fn != unsafe { nil }
&& c.table.cur_fn.params.filter(it.name == ident.name && it.is_mut).len > 0
if is_mut_param {
return

@medvednikov medvednikov Apr 20, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would add a comment // fix stack var outside usage when var is a mutable param for such blocks to make it clear what they are for in the future. I'll do it.

@medvednikov medvednikov merged commit 324edc6 into vlang:master Apr 20, 2025
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.

assigning to heap optional give v error: o cannot be assigned outside unsafe blocks as it might refer to an object stored on stack

2 participants