Repository navigation
Replace assertion errors on IR assumption violation - #7223
Conversation
with pedantic warnings.
| if newtarget.name not in scope.localvars: | ||
| wmsg = ( | ||
| f"variable name {newtarget.name!r} not in scope " | ||
| f"in {assign} on line {assign.loc}", | ||
| ) | ||
| warnings.warn(errors.NumbaIRAssumptionWarning(wmsg)) |
There was a problem hiding this comment.
| if newtarget.name not in scope.localvars: | |
| wmsg = ( | |
| f"variable name {newtarget.name!r} not in scope " | |
| f"in {assign} on line {assign.loc}", | |
| ) | |
| warnings.warn(errors.NumbaIRAssumptionWarning(wmsg)) | |
| if newtarget.name not in scope.localvars: | |
| wmsg = f"variable name {newtarget.name!r} not in scope" | |
| warnings.warn(errors.NumbaIRAssumptionWarning(wmsg, loc=assign.loc)) |
Does it help to use Numba's error message loc handling here?
There was a problem hiding this comment.
oh, i forgot that it has that
|
Note: verified behaviour in ec01acd against #7217 (comment) |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the patch. There's a few minor things to resolve but looks good else.
| # import logging | ||
| # logging.basicConfig(level=logging.DEBUG) |
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
stuartarchibald
left a comment
There was a problem hiding this comment.
Couple of suggestions to hopefully fix the build.
| # import logging | ||
| # logging.basicConfig(level=logging.DEBUG) |
There was a problem hiding this comment.
| # import logging | |
| # logging.basicConfig(level=logging.DEBUG) |
| # Verify the error message | ||
| self.assertRegex( | ||
| str(raises.exception), | ||
| r"variable name '[a-z]' not in scope", |
There was a problem hiding this comment.
| r"variable name '[a-z]' not in scope", | |
| r"variable '[a-z]' is not in scope", |
|
Btw, i'm trying out if the warning message should suggest users to report. Currently, the warning looks like: /path/to/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'a' is not in scope.
warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,
/path/to/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'b' is not in scope.
warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,With the suggestion: /path/to/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'b' is not in scope.
This error came from an internal pedantic check. Please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,
/path/to/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'a' is not in scope.
This error came from an internal pedantic check. Please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,The long message can be very annoying. |
|
RE #7223 (comment) Whilst the long messages are not great, I'd hope that the frequency at which this is hit is really small else it indicates a lot more problems. I guess this comes down to our confidence around having got Numba's internals sufficiently fixed up for this to be a rarity and definitely something that should be reported vs. an annoyance? |
|
|
||
| def run_pass(self, state): | ||
| # This is unreachable. SSA pass should have raised before this | ||
| # pass when run with `error.NumbaPedanicWarning`s raised as |
There was a problem hiding this comment.
| # pass when run with `error.NumbaPedanicWarning`s raised as | |
| # pass when run with `error.NumbaPedanticWarning`s raised as |
|
|
||
|
|
||
| pedantic_warning_info = """ | ||
| This error came from an internal pedantic check. Please report the error message |
There was a problem hiding this comment.
| This error came from an internal pedantic check. Please report the error message | |
| This warning came from an internal pedantic check. Please report the warning message |
(this will need a line wrap)
|
@esc, can you review this? It's just need a last look. |
esc
left a comment
There was a problem hiding this comment.
A few minor things to edit, ready to merge after that.
| return [pm] | ||
|
|
||
| @njit(pipeline_class=MyCompiler) | ||
| def dummy(x): |
There was a problem hiding this comment.
Perhaps add a comment explaining why this dummy is needed: multiple assignments to the same variable name are needed to trigger SSA.
Co-authored-by: esc <esc@users.noreply.github.com>
|
|
||
| feedback_details = """ | ||
| Please report the error message and traceback, along with a minimal reproducer | ||
| at: https://github.com/numba/numba/issues/new |
There was a problem hiding this comment.
Do you want to update this URL too, while there?
There was a problem hiding this comment.
Let's do this in a future PR.
esc
left a comment
There was a problem hiding this comment.
Changes are fine, I left one comment but that is perhaps something for a future PR.
Replace assertion errors on IR assumption violation
with pedantic warnings.
Closes #7217