-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: Nice errors for shim flag parsing #6737
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Ignored Deployments
|
🟢 Turbopack Benchmark CI successful 🟢Thanks |
🟢 CI successful 🟢Thanks |
Linux Benchmark for 22ea3eeClick to view benchmark
|
275fdaa
to
565e725
Compare
Linux Benchmark for 13c90b5Click to view benchmark
|
151e0be
to
adb8c44
Compare
adb8c44
to
38f8ad5
Compare
38f8ad5
to
d00ee50
Compare
d00ee50
to
d48f895
Compare
Linux Benchmark for 65d4d8eClick to view benchmark
|
Linux Benchmark for 02e3c1aClick to view benchmark
|
682368b
to
941ab9a
Compare
Linux Benchmark for 7c45361Click to view benchmark
|
Linux Benchmark for b1c68b7Click to view benchmark
|
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.
Nothing blocking, just a few suggestions/questions
flag2: Option<SourceSpan>, | ||
#[label("and here")] | ||
flag3: Option<SourceSpan>, | ||
// The user should get the idea after the first 4 examples |
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.
Haha, I would hope so. I would hope 2 examples would be enough.
) -> Vec<usize> { | ||
// Sort the indices to keep the invariant | ||
// that if i > j then output[i] > output[j] | ||
args_indices.sort(); |
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.
Do we need to require callers to keep up this invariant? e.g. If I pass in vec![2, 1]
and get out vec![3, 6]
would I be in a bad state when I try to map the indices to the args.
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.
Well I think the idea is you shouldn't be mapping these to args, since they're now indices into the string. And unless you parse the string it's not really easy to map the indices to the args.
crates/turborepo-lib/src/shim.rs
Outdated
pub(crate) fn get_indices_in_args_string( | ||
mut args_indices: Vec<usize>, | ||
args: impl Iterator<Item = impl Into<String>>, | ||
) -> Vec<usize> { |
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.
This feels like a "sharp" interface and I have a few suggestions:
- Make this a private function
- Since this is only used for making pretty error messages, I don't think we need to make this as perf sensitive as it currently is. We can generate the indices into the arg strings for all args and not just ones passed in as
arg_indices
. - Based on how we're using this. Do we just want to calculate the spans here instead of having callers do stuff like
(idx, "--flag".len())
?
Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
### What? Update SWC crates ### Why? It's required to fix some next.js isssues ### How? Closes PACK-2174 Turbopack counterpart: vercel/turborepo#6843 --- # Turbopack * vercel/turborepo#6737 <!-- Nicholas Yang - feat: Nice errors for shim flag parsing --> * vercel/turborepo#6494 <!-- Justin Ridgewell - Trace output's source maps through input's source map --> * vercel/turborepo#6778 <!-- Will Binns-Smith - turbopack-css: fix rule duplication --> * vercel/turborepo#6807 <!-- Mehul Kar - fix: add missing dependency to cargo lockfile --> * vercel/turborepo#6809 <!-- Nicholas Yang - refactor: Remove bookkeeping abstraction from turbo config --> * vercel/turborepo#6838 <!-- Nicholas Yang - fix: Allow for long symlinks by using append_link --> * vercel/turborepo#6845 <!-- Donny/강동윤 - perf: Use `&'static str` instead of `String` if possible --> * vercel/turborepo#6843 <!-- Donny/강동윤 - Update `swc_core` to `v0.87.10` -->
### What? Update SWC crates ### Why? It's required to fix some next.js isssues ### How? Closes PACK-2174 Turbopack counterpart: vercel/turborepo#6843 --- # Turbopack * vercel/turborepo#6737 <!-- Nicholas Yang - feat: Nice errors for shim flag parsing --> * vercel/turborepo#6494 <!-- Justin Ridgewell - Trace output's source maps through input's source map --> * vercel/turborepo#6778 <!-- Will Binns-Smith - turbopack-css: fix rule duplication --> * vercel/turborepo#6807 <!-- Mehul Kar - fix: add missing dependency to cargo lockfile --> * vercel/turborepo#6809 <!-- Nicholas Yang - refactor: Remove bookkeeping abstraction from turbo config --> * vercel/turborepo#6838 <!-- Nicholas Yang - fix: Allow for long symlinks by using append_link --> * vercel/turborepo#6845 <!-- Donny/강동윤 - perf: Use `&'static str` instead of `String` if possible --> * vercel/turborepo#6843 <!-- Donny/강동윤 - Update `swc_core` to `v0.87.10` -->
Description
This adds nice errors for shim parsing:
Testing Instructions
Added test for error output
Closes TURBO-1874