Remove WEXPERIMENTAL for "if with unsupported statements"#332
Remove WEXPERIMENTAL for "if with unsupported statements"#332mandolaerik wants to merge 2 commits intointel:mainfrom
Conversation
|
Verification #14013436: ✅ pass |
py/dml/messages.py
Outdated
| kind of statement as long as the `#if` condition doesn't reference | ||
| any identifiers other than `dml_1_2`, `true`, and `false`. | ||
| """ | ||
| fmt = "object of type %s not allowed inside `#if`" |
There was a problem hiding this comment.
%s declarations are not allowed inside #if
There was a problem hiding this comment.
Or maybe %s statements are not ...? Note that this is a best-effort error message, will e.g. say "extern_typedef statements are ..." which is not optimal but good enough. The important ones are param, import and template, and we get those right at least.
There was a problem hiding this comment.
How come you prefer statements instead of declarations? Sure, we have a concept of "object statements", but as you point out, many of the forbidden things doesn't fit inside that concept; and we have "declaration" as a collective name for object statements and global declarations (which sometimes is not ideal; for example in our documentation we often say "param declarations" as a collective name for all param object statements, which I dislike, but that's what we do. If we say "param declarations not allowed inside #if" I don't think people would get confused.)
There was a problem hiding this comment.
Also, this error message should be tagged version = "1.4". Toplevel if logic can only happen in 1.4 code.
There was a problem hiding this comment.
I just realized. The emission of this error message disagrees with non-toplevel ifs. They crop up from invocations of validate_if_body() from dmlparse.py; and those use ECONDP, ECONDT and ECONDINEACH. We'll have to address that; replace them all with EBADCONDSTMT?
There was a problem hiding this comment.
I don't see a contradiction here. The messages for non-top-level ifs do not need to mention that top-level ifs have a special case. They are also more specific than top-level ifs, and I don't see a problem with that. I would probably not oppose unifying the messages, but that can be done in a separate PR.
There was a problem hiding this comment.
The messages for non-top-level ifs do not need to mention that top-level ifs have a special case.
Well, no, I'm not arguing that (we've settled that a time ago.) I'm confused why you're bringing that up; what are you addressing with that statement? Or are you talking about documentation -- "the documentation for error messages of non-top-level ifs do not need to mention that top-level ifs have a special case, thus it's a good thing they're separate error classes?" I don't buy that argument at all.
They are also more specific than top-level ifs, and I don't see a problem with that.
Neither do I. What I have a problem with is that your PR introduces an inconsistency about what error classes are used for reporting the same kind of error (from the user's perspective.) Because of that, I don't buy the argument that unification can be done in a separate PR.
Thus I'm arguing either you replace ECONDP, ECONDT, and ECONDINEACH all with EBADCONDSTMT, or you replace EBADCONDSTMT with uses of ECONDP, ECONDT, and ECONDINEACH. Either way, you can implement it by having ast builder pass what forbidden declarations are in use, and then you can either report ECONDP/ECONDT/ECONDINEACH for each of them; or you can pass the sites and declaration kinds to EBADCONDSTMT to each be printed via print_site_message.
There was a problem hiding this comment.
What I have a problem with is that your PR introduces an inconsistency
It's not an inconsistency toward the end user. The same kind of mistake will always give an error, and in some circumstances it will use a somewhat different wording (essentially because there's more error cases to cover). The end result is that the user will read the message and adjust their code, and then they will not see the message again. What's the problem? The error tags are mainly related to our internal testing.
Hm, what we could do is to pick a more directed message, like "not allowed inside if, except dml_1_2" if the violating statement is one that only can appear on top level, like a typedef or template. And use a plain ECONDP etc for the other cases. Not sure if that makes anyone happier, though.
There was a problem hiding this comment.
Thus I'm arguing either you replace
ECONDP,ECONDT, andECONDINEACHall withEBADCONDSTMT, or you replaceEBADCONDSTMTwith uses ofECONDP,ECONDT, andECONDINEACH.
I still insist on this. It makes no sense to me to have different error classes be used depending on if the #if is on top-level or not. And it does matter to the end user since we talk about errors in terms of error tags both in documentation and in conversation with our users (speaking of which we still need to enforce -T to be always on. I don't remember why we've procrastinated that).
Separately, you haven't addressed the original problem I raised of the fmt formulation being bad
There was a problem hiding this comment.
Honestly I like the idea of getting rid of ECONDP and ECONDT in favor of EBADCONDSTMT. In any case, just to reiterate, you do not need to tailor the error message to be different for top-level #ifs. If you want, you could tailor the error message for top-level #ifs to say "not allowed inside if, except dml_1_2" or something similar like you suggest, but that's entirely up to you; though I'll note that an accurate formulation would prove difficult, especially since we're gonna want to allow the use of _breaking_change params in the conditionals of special top-level #ifs.
| various operations that rely on the `register_view` interface, such as the | ||
| `dev_util.bank_regs` function and the `write-device-reg` and `probe-address` | ||
| CLI commands. | ||
| - `note 6` DMLC no longer emits warnings saying |
There was a problem hiding this comment.
will no longer emit the subset of
WEXPERIMENTALwarnings saying...
maybe?
There was a problem hiding this comment.
I chose not to because I didn't want to bore the reader with details, but it does make sense to mention WEXPERIMENTAL because of how --no-warn=WEXPERIMENTAL is sprinkled in makefiles.
There was a problem hiding this comment.
Yeah that's mostly why I figured it was a good idea.
There was a problem hiding this comment.
still not mention of WEXPERIMENTAL, here. I still think you should do so, but whichever way you go about it is up to you.
RELEASENOTES.md
Outdated
| `param` and `template` are forbidden inside `#if`, but a special exception | ||
| allows forbidden statements to appear specifically inside an `#if (dml_1_2)` | ||
| block. The warning message was meant to highlight this irregularity, but | ||
| caused more harm than good. |
There was a problem hiding this comment.
more harm than good; error messages surrounding the special case have been improved instead.
| various operations that rely on the `register_view` interface, such as the | ||
| `dev_util.bank_regs` function and the `write-device-reg` and `probe-address` | ||
| CLI commands. | ||
| - `note 6` DMLC no longer emits warnings saying |
There was a problem hiding this comment.
Toplevel if logic is 1.4 exclusive, and thus so should this releasenote.
There was a problem hiding this comment.
I disagree. You are right that they are exclusive for 1.4 files, but their only use is in the context of 1.2 devices: The only allowed identifier is dml_1_2, so the construct is only relevant for common code intended for use in 1.2.
There was a problem hiding this comment.
so the construct is only relevant for common code intended for use in 1.2.
Only for the time being. I think we've both agreed upon extending the conditional to also allow the use of the compat params?
Nevertheless, I guess this is a matter of perspective of where a releasenote belongs. I was thinking "1.4, because this feature is only available in 1.4 files", while you're arguing the use of it is only significant due to how it impact 1.2 devices. Because of that, I'm fine with it being in RELEASENOTES.dml; but I would note that your argument sounds like it'd belong in RELEASENOTES-1.2.md, which I would heavily disagree with.
There was a problem hiding this comment.
The releasenote split between 1.2/1.4/both is inherently fuzzy and somewhat questionable. What matters the most is that the end-user sees a note attached to the right package version, this happens no matter what releasenote file we pick; the choice of file is not so important.
I guess the advantage of the split is that many syntax additions are 1.4 specific, and putting it in -1.4 eliminates the need to mention this in text.
I think it would make sense at least to merge RELEASENOTES and RELEASENOTES-1.2. A total 7 notes were 1.2 specific over the past 3 years.
There was a problem hiding this comment.
So what action are we taking?
e5f4b1b to
cd00065
Compare
|
Verification #14117325: ✅ pass |
3a45f08 to
222d6aa
Compare
|
PR Verification: ✅ success |
py/dml/messages.py
Outdated
| kind of statement as long as the `#if` condition doesn't reference | ||
| any identifiers other than `dml_1_2`, `true`, and `false`. | ||
| """ | ||
| fmt = "object of type %s not allowed inside `#if`" |
There was a problem hiding this comment.
Thus I'm arguing either you replace
ECONDP,ECONDT, andECONDINEACHall withEBADCONDSTMT, or you replaceEBADCONDSTMTwith uses ofECONDP,ECONDT, andECONDINEACH.
I still insist on this. It makes no sense to me to have different error classes be used depending on if the #if is on top-level or not. And it does matter to the end user since we talk about errors in terms of error tags both in documentation and in conversation with our users (speaking of which we still need to enforce -T to be always on. I don't remember why we've procrastinated that).
Separately, you haven't addressed the original problem I raised of the fmt formulation being bad
| various operations that rely on the `register_view` interface, such as the | ||
| `dev_util.bank_regs` function and the `write-device-reg` and `probe-address` | ||
| CLI commands. | ||
| - `note 6` DMLC no longer emits warnings saying |
There was a problem hiding this comment.
So what action are we taking?
| various operations that rely on the `register_view` interface, such as the | ||
| `dev_util.bank_regs` function and the `write-device-reg` and `probe-address` | ||
| CLI commands. | ||
| - `note 6` DMLC no longer emits warnings saying |
There was a problem hiding this comment.
still not mention of WEXPERIMENTAL, here. I still think you should do so, but whichever way you go about it is up to you.
|
|
||
| A special exception is that a `#if` on top scope may contain any | ||
| kind of statement as long as the `#if` condition doesn't reference | ||
| any identifiers other than `dml_1_2`, `true`, and `false`. |
There was a problem hiding this comment.
wait. actually you can't reference dml_1_4. what? Did I trick myself into believing that? That's pretty bad since I've communicated that you're able to reference dml_1_4 to everyone I've explained experimental #if to...
That feels like a bad inconsistency. I mean, I got confused about it. Maybe you should add dml_1_4 to be able to be referenced. I ask that totally not at all out of a self-interested need to retroactively make my improper communication proper, I promise
|
|
||
| A special exception is that a `#if` on top scope may contain any | ||
| kind of statement as long as the `#if` condition doesn't reference | ||
| any identifiers other than `dml_1_2`, `true`, and `false`. |
There was a problem hiding this comment.
wait. actually you can't reference dml_1_4. what? Did I trick myself into believing that? That's pretty bad since I've communicated that you're able to reference dml_1_4 to everyone I've explained experimental #if to...
That feels like a bad inconsistency. I mean, I got confused about it. Maybe you should add dml_1_4 to be able to be referenced. I ask that totally not at all out of a self-interested need to retroactively make my improper communication proper, I promise
|
|
||
| As a special exception, an `#if` statement that appears on top level is allowed | ||
| to contain any type of statement, as long as the condition doesn't reference | ||
| any identifiers other than `dml_1_2`, `true` and `false`. |
There was a problem hiding this comment.
If you do add dml_1_4 you'll need to update this accordingly.
There was a problem hiding this comment.
The reason for "only 1.2" is that I want to encourage users to consistently use the dml_1_2 form, for two reasons (or both are really the same reason):
- Currently dml_1_2 is equivalent to !dml_1_4, but in a world where 1.2/1.4/1.6 coexist they are not, and in this case dml_1_2 better expresses what you mean: you want stuff to change when you switch between "old" and "new". Comparing for equality to 1.2 is future proof because we will never add new old versions.
- Saying 1.2 in code is a clear marker that the
#ifis a legacy thing that can safely be removed once the codebase is free from DML 1.2 code. If we say 1.4, then this is less obvious.
For this reason, I don't yet see a real use case where dml_1_4 is preferable over dml_1_2, so I don't see a compelling reason to spend time here.
There was a problem hiding this comment.
MMmmfmffhghh... fine.
There was a problem hiding this comment.
actually, no -- not fine. I don't understand why your favored approach is to use the restrictions placed on top-level #ifs as a vehicle against dml_1_4. If you dislike dml_1_4 so much and want to discourage its use -- why does it exist at all in the first place? I'd prefer we remove dml_1_4 entirely rather than having this strange inconsistency.
222d6aa to
496bac9
Compare
|
PR Verification: ❌ failure |
Remove WEXPERIMENTAL for "if with unsupported statements"