You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oo[777] is not a valid octal literal as this would represent 9 and not 8 high bits. Apparently we don't surface an error message for that and thus we fall back to parsing this as a bare word and thus try to find the binary named like that.
I think while your reasoning here makes sense for the octal int literal 0o77777 etc. I am not sure if we should use this carry semantics for the binary/byte string literals:
In a C string you would for example write:
charstr[] ="\377\377\377\0";
with a readable Nushell equivalent:
letstr=0o[377377377000] # Note that you currently need to pass multiples of three for the octal coded byte string which makes the chunking consistent
If you want to express the carrying single int semantics you have the 0o1234567 syntax available and can convert into binary.
and #16678 (comment) for a limited alternative if you want to express this carry across byte boundaries for short (i64) strings of octal.
Activity
baehyunsol commentedon Jun 30, 2023
I'll try further debugging this evening!
sholderbach commentedon Jun 30, 2023
Oo[777]is not a valid octal literal as this would represent 9 and not 8 high bits. Apparently we don't surface an error message for that and thus we fall back to parsing this as a bare word and thus try to find the binary named like that.fdncred commentedon Jun 30, 2023
I didn't even know that
0o[7]would work. I thought the syntax was just0o777sophiajt commentedon Jul 2, 2023
@fdncred @sholderbach it's for binary data rather than an integer.
This should just work as stated. I think there's a bug in the octal binary parser.
sholderbach commentedon Jul 2, 2023
But what would be the meaning of 777?
1 377or7 077baehyunsol commentedon Jul 2, 2023
It's just
777, it should be that0o[777] == 0b[111 111 111]because0o777 == 0b111_111_111. nushell left-pads incomplete bytes with zeros.The above should be
sholderbach commentedon Jul 3, 2023
You are both right @jntrnr and @baehyunsol. Was very byte brained late last night.
sholderbach commentedon Sep 17, 2025
Closing as this carrying behavior for octal encoded binary strings is likely more confusing.
See #16678 (comment)
and #16678 (comment) for a limited alternative if you want to express this carry across byte boundaries for short (i64) strings of octal.
For better erros we will have #16688
Improve error messages for invalid binary strings (#16688)