Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor name poisoning tests to be more organized, complete and consistent #4987

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

bricknerb
Copy link
Contributor

This is also following #4900 (comment), which points that name poisoning tests are not in the correct place.
Part of #4622.

…istent

This is also following carbon-language#4900 (comment), which points that name poisoning tests are not in the correct place.
Comment on lines -5 to -6
// EXTRA-ARGS: --no-dump-sem-ir
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sem-ir dump shows what symbols are poisoned so it's useful to verify the behavior or reason about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, just know that the sem-ir dumps are quite long and it is easy to miss information in there.

Comment on lines 17 to 20
// N.F uses N.C and not C.
namespace N;
class N.C;
fn N.F(x: C);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like there should be a call that verifies the truth of the comment, like:

fn TestCall(y: N.C) {
  // `N.F` accepts an `N.C` not a `package.C`.
  N.F(y);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
Note though that this is implicitly tested in the sem ir dump.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is much better to have a test that will fail if something goes wrong than a change that needs to be manually reviewed to see that it is broken.

// N.F uses N.I and not I.
namespace N;
interface N.I {}
fn N.F(x: I);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn N.F(x: I);
fn N.F(x:! I);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you clarify why does using generics help here?
I've tried this and the below and I get generics related errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

The values of an interface are conceptually compile-time values. x: I would almost certainly be a mistake in user code and is something we might mark as an error in the future. What error do you get?

@bricknerb bricknerb requested a review from josh11b February 21, 2025 11:06
Comment on lines -5 to -6
// EXTRA-ARGS: --no-dump-sem-ir
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, just know that the sem-ir dumps are quite long and it is easy to miss information in there.

Comment on lines 17 to 20
// N.F uses N.C and not C.
namespace N;
class N.C;
fn N.F(x: C);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is much better to have a test that will fail if something goes wrong than a change that needs to be manually reviewed to see that it is broken.

// N.F uses N.I and not I.
namespace N;
interface N.I {}
fn N.F(x: I);
Copy link
Contributor

Choose a reason for hiding this comment

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

The values of an interface are conceptually compile-time values. x: I would almost certainly be a mistake in user code and is something we might mark as an error in the future. What error do you get?

namespace N2;
namespace N2.N1;
alias N2.N3 = N1;

class N2.N1.C {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class N2.N1.C {}
class N2.N1.C {}
class N1.C {}

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants