Skip to content

ast, markused, checker: fix mark methods into used-list, when generics as receivers(fix #20509)#20527

Merged
spytheman merged 3 commits intovlang:masterfrom
shove70:skip-unused
Jan 14, 2024
Merged

ast, markused, checker: fix mark methods into used-list, when generics as receivers(fix #20509)#20527
spytheman merged 3 commits intovlang:masterfrom
shove70:skip-unused

Conversation

@shove70
Copy link
Copy Markdown
Contributor

@shove70 shove70 commented Jan 14, 2024

  1. Fixed cgen: -skip-unused problem #20509
  2. Add tests.
import time

fn foo[T](val T) string {
	str_value := val.format_rfc3339_nano()
	return str_value
}

fn main() {
	println(foo(time.Time{}))
}

v -skip-unused run a.v:

0000-00-00T00:00:00.000000000Z

Comment thread vlib/v/tests/skip_unused/generics_as_receiver.vv Outdated
Comment thread vlib/v/markused/walker.v Outdated
@shove70 shove70 marked this pull request as draft January 14, 2024 09:50
@spytheman
Copy link
Copy Markdown
Contributor

It is very weird that vab failed compilation on the CI to me. The code in the PR, can just protect more code to not be stripped, yet the failure indicates the opposite on first glance 🤔 .

@shove70
Copy link
Copy Markdown
Contributor Author

shove70 commented Jan 14, 2024

It is very weird that vab failed compilation on the CI to me. The code in the PR, can just protect more code to not be stripped, yet the failure indicates the opposite on first glance 🤔 .

Yeah, it's a little weird. I'll do more research

@shove70 shove70 changed the title markused: fix mark methods into used-list, when generics as receivers(fix #20509) ast, markused, checker: fix mark methods into used-list, when generics as receivers(fix #20509) Jan 14, 2024
@shove70 shove70 marked this pull request as ready for review January 14, 2024 15:00
@shove70 shove70 marked this pull request as draft January 14, 2024 15:06
@shove70 shove70 marked this pull request as ready for review January 14, 2024 16:31
Comment thread vlib/v/markused/walker.v
Comment on lines +521 to +522
// We need the receiver to be T in cgen.
// so save the concrete type to node.receiver_concrete_type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That comment should be deleted imho. markused does not modify receiver_concrete_type.

Comment thread vlib/v/ast/ast.v
Comment thread vlib/v/checker/fn.v
Copy link
Copy Markdown
Contributor

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit ca3da8b into vlang:master Jan 14, 2024
@shove70 shove70 deleted the skip-unused branch January 14, 2024 22:29
@shove70
Copy link
Copy Markdown
Contributor Author

shove70 commented Jan 15, 2024

This indicates that the comments are still not clear enough, so I'll have to edit them :)

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.

cgen: -skip-unused problem

2 participants