Skip to content

fix: parenthesize pointer newtype cast in match patterns#332

Merged
ivov merged 1 commit into
mainfrom
newtype-ref-pattern-cast
May 7, 2026
Merged

fix: parenthesize pointer newtype cast in match patterns#332
ivov merged 1 commit into
mainfrom
newtype-ref-pattern-cast

Conversation

@ivov
Copy link
Copy Markdown
Owner

@ivov ivov commented May 7, 2026

Matching a newtype over Ref<T> failed to compile because the destructuring path emitted an unparenthesized pointer cast like *int(w), which Go parses as multiplication. The non-pattern form w.0 already parenthesizes pointer types; pattern emission now does the same, producing (*int)(w).

struct Wrap(Ref<int>)

fn main() {
  let mut x = 5
  let w = Wrap(&x)
  match w {
    Wrap(r) => fmt.Println(r.*),
  }
}

@ivov ivov merged commit 4035606 into main May 7, 2026
12 checks passed
@ivov ivov mentioned this pull request May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Released in lisette-v0.2.1

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.

1 participant