Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a semantic typing issue around tuple constructors when the expected tuple element types are view types (var/lent), which could lead to incorrect typing and downstream failures (notably for (lent T, lent T) scenarios referenced in #24723).
Changes:
- Update
changeTypeto avoid rewriting tuple-constructor element node types when the target element type isvar/lent. - Add a regression test ensuring tuple yields requiring
lentelements still correctly error when an element has no address.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/lent/tlent_tuple_address.nim | Adds a regression test for tuple yields with lent elements that should fail due to an unaddressable expression. |
| compiler/semexprs.nim | Prevents changeType from force-typing tuple elements to var/lent, avoiding incorrect view-typing of non-addressable expressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref #25783
This pull request addresses an issue with addressability of tuple elements of type
lentorvarin Nim, ensuring that expressions involving these types are handled correctly during type changes. The main changes introduce a check to prevent attempting to change the type of tuple elements that are views (varorlent), and a new test is added to verify the correct error is raised when trying to take the address of such elements.Type system and semantic analysis improvements:
isViewTargettemplate insemexprs.nimto check if a type is a view (varorlent), and updatedchangeTypeto skip type changes for tuple elements that are views. This prevents invalid addressability operations on these types. [1] [2]Testing:
tlent_tuple_address.nimto verify that attempting to take the address of tuple elements of typelentcorrectly produces an "expression has no address" error.