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

Quote maybe atoms #401

Closed
wants to merge 1 commit into from
Closed

Quote maybe atoms #401

wants to merge 1 commit into from

Conversation

sile
Copy link
Contributor

@sile sile commented Nov 1, 2023

Proposed Changes

Basically, ra codebase quotes maybe atoms (to support the maybe feature in the future I guess).
However there are some maybe atoms that are not quoted, and ra can't be compiled if the maybe feature is enabled.
This PR fixes this problem.
Of course, this is not a critical problem. So, feel free to close this PR if it seems not needed.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (correction or otherwise)
  • Cosmetics (whitespace, appearance)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

If this is a relatively large or complex change, kick off the discussion by
explaining why you chose the solution you did and what alternatives you
considered, etc.

@michaelklishin
Copy link
Member

maybe in this case is a type name. It's a bit unexpected that the same quoting rules would apply to type specs since there cannot be any conflict with the maybe keyword.

Also, Ra is compiled and passes all tests on CI on Erlang 26 (where maybe is supposedly always enabled). But Make-based tests fail with this PR.

What am I missing?

michaelklishin added a commit that referenced this pull request Nov 1, 2023
so that we don't have to think about quoting.
'maybe' is a keyword in Erlang 25+ and as of 26,
it is an always-on language feature.

Closes #401
@michaelklishin
Copy link
Member

Maybe (pun intended) we should sidestep the issue entirely :) #402

@sile
Copy link
Contributor Author

sile commented Nov 1, 2023

Thank you for your comments.

Seeing the OTP 26 highlight, the runtime's maybe feature is enabled by default, but the compiler's is not.
If we enable the compiler's maybe feature, ra cannot be compiled as follows:

// Erlang/OTP version
$ erl -boot start_clean -noshell -eval 'io:format(erlang:system_info(system_version)).' -s init stop
Erlang/OTP 26 [erts-14.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

// Clone ra
$ git clone https://github.com/rabbitmq/ra.git 
$ cd ra/

// Compile ra_log.erl without and with the maybe_expr compile feature 

// without (default) => OK
$ erlc src/ra_log.erl

// with => NG
$ erlc -enable-feature maybe_expr src/ra_log.erl
src/ra_log.erl:549:6: syntax error before: 'maybe'
%  549|     {maybe(log_entry()), state()}.
%     |      ^

@sile
Copy link
Contributor Author

sile commented Nov 1, 2023

Maybe (pun intended) we should sidestep the issue entirely :) #402

The approach of #402 is perfect for me :)
Thank you!

@sile sile deleted the quote-maybe-atom branch November 1, 2023 11:04
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.

2 participants