Skip to content

fix: report tail-position return-value mismatches#254

Merged
ivov merged 2 commits into
mainfrom
discarded-values
May 1, 2026
Merged

fix: report tail-position return-value mismatches#254
ivov merged 2 commits into
mainfrom
discarded-values

Conversation

@ivov
Copy link
Copy Markdown
Owner

@ivov ivov commented May 1, 2026

Tail-position type mismatches in fn and lambda bodies are now reported as errors, not silently discarded, matching Rust semantics and preventing invalid Go output for cases like fn test() { "test".length() }

fn test() {
  42
}
[error] Mismatch between return type and return value
  ╭─[test.lis:3:3]
1 │
2 │ fn test() {
  ·           ┬
  ·           ╰── has `()` as implicit return type
3 │   42
  ·   ─┬
  ·    ╰── returns `int`
4 │ }
  ╰────
help: If the `()` return type is intended, discard the return value with `let _ = ...`. 
If the `int` return value is intended, add `-> int` to the function signature · code:
[lint.mismatched_return_value]

Fix #252

@ivov ivov merged commit 47ada42 into main May 1, 2026
11 checks passed
@ivov ivov mentioned this pull request May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Released in lisette-v0.1.24

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.

Functions returning unit can lead to invalid go code, and brakes lisette type semantics

1 participant