-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
don't capture arrays/tuples in BoundsError
#43738
Open
aviatesk
wants to merge
1
commit into
master
Choose a base branch
from
avi/boundserror
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,11 +139,19 @@ JL_DLLEXPORT void JL_NORETURN jl_atomic_error(char *str) // == jl_exceptionf(jl_ | |
jl_throw(jl_new_struct(jl_atomicerror_type, msg)); | ||
} | ||
|
||
void JL_NORETURN jl_throw_bounds_error(jl_value_t *v, jl_value_t *t) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this code have a special meaning in the context of the other changes, or is this just a refactor? |
||
{ | ||
jl_value_t **args; | ||
JL_GC_PUSHARGS(args, 2); | ||
args[0] = v; | ||
args[1] = t; | ||
jl_throw(jl_apply_generic((jl_value_t*)jl_boundserror_type, args, 2)); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_bounds_error(jl_value_t *v, jl_value_t *t) | ||
{ | ||
JL_GC_PUSH2(&v, &t); // root arguments so the caller doesn't need to | ||
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t)); | ||
jl_throw_bounds_error(v, t); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_v(jl_value_t *v, jl_value_t **idxs, size_t nidxs) | ||
|
@@ -152,7 +160,7 @@ JL_DLLEXPORT void JL_NORETURN jl_bounds_error_v(jl_value_t *v, jl_value_t **idxs | |
// items in idxs are assumed to already be rooted | ||
JL_GC_PUSH2(&v, &t); // root v so the caller doesn't need to | ||
t = jl_f_tuple(NULL, idxs, nidxs); | ||
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t)); | ||
jl_throw_bounds_error(v, t); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_tuple_int(jl_value_t **v, size_t nv, size_t i) | ||
|
@@ -169,15 +177,15 @@ JL_DLLEXPORT void JL_NORETURN jl_bounds_error_unboxed_int(void *data, jl_value_t | |
JL_GC_PUSH2(&v, &t); | ||
v = jl_new_bits(vt, data); | ||
t = jl_box_long(i); | ||
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t)); | ||
jl_throw_bounds_error(v, t); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_int(jl_value_t *v JL_MAYBE_UNROOTED, size_t i) | ||
{ | ||
jl_value_t *t = NULL; | ||
JL_GC_PUSH2(&v, &t); // root arguments so the caller doesn't need to | ||
t = jl_box_long(i); | ||
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t)); | ||
jl_throw_bounds_error(v, t); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_ints(jl_value_t *v JL_MAYBE_UNROOTED, | ||
|
@@ -191,7 +199,7 @@ JL_DLLEXPORT void JL_NORETURN jl_bounds_error_ints(jl_value_t *v JL_MAYBE_UNROOT | |
jl_svecset(t, i, jl_box_long(idxs[i])); | ||
} | ||
t = jl_f_tuple(NULL, jl_svec_data(t), nidxs); | ||
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t)); | ||
jl_throw_bounds_error(v, t); | ||
} | ||
|
||
JL_DLLEXPORT void JL_NORETURN jl_eof_error(void) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit worried about that. When I joked offline that we "supported" this, @JeffBezanson was "We do not!".
I think a better approach is to define a
Core.throw_bounds_error
that is defined in the inference world-age.and have
jl_throw_bounds_error
invoke in that world-age.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we really need to (or should) call
summary
here; saving the size and type should be enough.To handle calling
size
, we could define constructors here only for Array and Tuple, and add a constructor in Base for other types so it can call Base.size. (I hope to have a better general solution for this one day, but for now this is how it is.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size
->axes