Repository: nushell/nushell (Rust)

Issue:
Filesieze literal conflicts with hex integer literal
### Describe the bug

Hexadecimal literal ending with `b` is parsed as filesize (bytes) and fails.

### How to reproduce

```
> 0x6b
Error:   × filesize value must be a number
   ╭─[entry #1:1:1]
 1 │ 0x6b
   · ─┬─
   ·  ╰── not a number
   ╰────
```

### Expected behavior

`107`

### Screenshots

_No response_

### Configuration

| key                | value                                                                                                           |
| ------------------ | --------------------------------------------------------------------------------------------------------------- |
| version            | 0.80.1                                                                                                          |
| branch             | main                                                                                                            |
| commit_hash        | db4b26c1acdb62e51d3f8615f8bb23b5045a79a4                                                                        |
| build_os           | linux-x86_64                                                                                                    |
| build_target       | x86_64-unknown-linux-gnu                                                                                        |
| rust_version       | rustc 1.67.1 (d5a82bbd2 2023-02-07)                                                                             |
| rust_channel       | 1.67.1-x86_64-unknown-linux-gnu                                                                                 |
| cargo_version      | cargo 1.67.1 (8ecd4f20a 2023-01-10)                                                                             |
| build_time         | 2023-05-23 23:22:04 +03:00                                                                                      |
| build_rust_channel | release                                                                                                         |
| features           | default, extra, sqlite, trash, which, zip                                                                       |
| installed_plugins  | from eml, from ics, from ini, from vcf, gstat, hist, inc, plot, query, query json, query web, query xml, xyplot |

### Additional context

_No response_


Discussion: oh, wow, that's interesting. i'm surprised we've never seen that before.
Maybe a recent regression.  I know it was working a while ago, when I last touched the parser.
on 0.80.0 it works fine
```
> 0x6b
107
```
Interesting, then it must be some recent regression.
Just bisected.
```
0e4729b203a042c5851f8d58ec3d12a60e3d58c5 is the first bad commit
commit 0e4729b203a042c5851f8d58ec3d12a60e3d58c5
Author: mike <98623181+1Kinoti@users.noreply.github.com>
Date:   Thu May 18 02:54:35 2023 +0300

    improve parsing of values with units (#9190)
```
@1Kinoti If I bisected properly, it appears that #9190 caused the issue mentioned here. If you have time, would you mind looking into it?
i see the issue, `0x6b`, is split into `0x6` and `b` (where `b` is a valid unit), then we check to see if `0x6` is a number which according to filesize parsing it's not, so we emit this error. this is fixable



Fix (patch):
diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs
index 1446e6e97eca3..a9e63c5318f0e 100644
--- a/crates/nu-parser/src/parser.rs
+++ b/crates/nu-parser/src/parser.rs
@@ -2217,6 +2217,12 @@ pub fn parse_filesize(working_set: &mut StateWorkingSet, span: Span) -> Expressi
 
     let bytes = working_set.get_span_contents(span);
 
+    // the hex digit `b` might be mistaken for the unit `b`, so check that first
+    if bytes.starts_with(b"0x") {
+        working_set.error(ParseError::Expected("filesize with valid units", span));
+        return garbage(span);
+    }
+
     match parse_unit_value(bytes, span, FILESIZE_UNIT_GROUPS, Type::Filesize, |x| {
         x.to_uppercase()
     }) {