Skip to content
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

No version of Solidity supports octal numbers #1604

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

seanyoung
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f401069) 87.99% compared to head (8cdf512) 88.00%.

❗ Current head 8cdf512 differs from pull request most recent head d0eae6e. Consider uploading reports for the commit d0eae6e to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1604   +/-   ##
=======================================
  Coverage   87.99%   88.00%           
=======================================
  Files         133      133           
  Lines       64953    64970   +17     
=======================================
+ Hits        57156    57176   +20     
+ Misses       7797     7794    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seanyoung seanyoung marked this pull request as ready for review November 30, 2023 11:02
int public test5 = -00;
int public test6 = -0;
int public test7 = -01e1;
int public test8 = -09.1 * 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these numbers called octal?
If I am understanding this correctly, octals can only have digits between 0 and 7.
https://en.wikipedia.org/wiki/Octal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're using the octal notation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're using the octal notation

There cannot be a 9 digit in octal.

Copy link
Contributor

@LucasSte LucasSte Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solidity documentation says:

Octal literals do not exist in Solidity and leading zeros are invalid.

A number with leading zeros is not necessarily an octal. All the numbers you wrote here are decimals, not octals. This is the definition of an octal: https://en.wikipedia.org/wiki/Octal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the message should be say that leading zeros are not permitted. Even though C considers numbers with leading zeros as octals, this is not a patterns across programming languages. See Python:

>>> a = 012
  File "<stdin>", line 1
    a = 012
        ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

Copy link
Contributor Author

@seanyoung seanyoung Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number with leading zeros is not an octal.

A number of with a leading zero is an octal in many if not most programming languages.

Copy link
Contributor

@LucasSte LucasSte Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is allowed in Rust and is not an octal.

fn main() {
    let a = 0120;
    println!("{a}");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the message. @LucasSte is probably not the only one who does not know octal notation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number with leading zeros is not an octal.

A number of with a leading zero is an octal in many if not most programming languages.

It is NOT in Rust, Python, Zig, OCaml, Ruby.
It is in C/C++, JavaScript/Typecript, Java, Golang, PHP.

We have a tie!

Signed-off-by: Sean Young <sean@mess.org>
@seanyoung seanyoung merged commit 8fdb728 into hyperledger-solang:main Dec 1, 2023
18 checks passed
@seanyoung seanyoung deleted the octal branch December 1, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants