Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Confusing error message when not using parametric substitution correctly #30

Closed
Tracked by #31
Emoun opened this issue Sep 10, 2021 · 2 comments
Closed
Tracked by #31
Labels
D-accepted A decision (D) has been made and the issue will be worked on I-bug This issue (I) regards a (potential) bug in the project T-accepted Triage (T): Initial review accepted issue/PR as valid

Comments

@Emoun
Copy link
Owner

Emoun commented Sep 10, 2021

Situation:

When trying to use parametric substitution but forgetting to encapsulate the argument to a parametrized identifier in [], the resulting error message is confusing.

Reproduction:

A simple example is to try and create a duplicate with and without &:

#[duplicate(refs(T); [& T]; [T])]
fn from(x: refs(Bits<1, false>)) -> bool {
    x.value == 1
}

Expected Behavior:

An error message pointing out that the argument to refs is not encapsulated in [].

Actual Behavior:

The error message:

message: Error substituting identifier with arguments: ()

Affected Versions:

Only tested on 0.3.0

Local Environment:

Using default features

Miscellaneous:

@Emoun Emoun added D-discussion A decision (D) has not been made yet and is open to discussion I-bug This issue (I) regards a (potential) bug in the project T-accepted Triage (T): Initial review accepted issue/PR as valid labels Sep 10, 2021
@Emoun Emoun mentioned this issue Sep 14, 2021
12 tasks
@Emoun
Copy link
Owner Author

Emoun commented Sep 14, 2021

Implementing better error messages cannot commence before we have a test setup ready for testing the error messages.
Such a test setup should be very similar to our expand-tests using macrotest. However, the difference is that the existing tests check that compilation succeeds while the tests needed here check that compilation fails with some error. This cannot be done using macrotest.
trybuild is available for this. However, as our experience has shown (eupn/macrotest#41, eupn/macrotest#43), trybuild will need the ability to configure features at the least (see dtolnay/trybuild#108).

@Emoun Emoun added D-accepted A decision (D) has been made and the issue will be worked on and removed D-discussion A decision (D) has not been made yet and is open to discussion labels Sep 29, 2021
@Emoun
Copy link
Owner Author

Emoun commented Feb 26, 2023

Using duplicate_macrotest finally allows to test errors.

Fixed awaiting next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-accepted A decision (D) has been made and the issue will be worked on I-bug This issue (I) regards a (potential) bug in the project T-accepted Triage (T): Initial review accepted issue/PR as valid
Projects
None yet
Development

No branches or pull requests

1 participant