Repository navigation
A magic comment in ruby's two forms, and only those - #266
Merged
Merged
Conversation
The plain form is one pair and nothing else; the emacs form is the pairs between two -*-, separated by ; or blanks. The evaluator took a key after a ; anywhere: # frozen_string_literal: false; shareable_constant_value: literal made constants shareable. The warning of a late frozen_string_literal reads the same two forms.
284km
commented
Nov 25, 2026
284km
left a comment
Owner
Author
There was a problem hiding this comment.
Reviewed 41b55e5. No findings.
-
The evaluator now reads magic comments by ruby's rules.
- A plain
#comment counts only when the whole comment is exactly onekey: valuepair; a second pair after;and trailing text are ignored. - The emacs
-*- … -*-form reads pairs separated by;or spaces, and skips words without:. - The late-
frozen_string_literalwarning follows the same rule.
- A plain
-
Ran 12 comment forms on the author's build at this head (clean tree, binary newer than the sources). Each form was followed by
A = [1]andS = "s", with-W1, against ruby 4.0.10, the evaluator andMERE_RUBY_VM=1. The forms:- a plain pair, and a plain pair followed by
; second; -*-with one pair, two pairs, andcodingplus a pair;- no space; dashes in the key; an upper-case key;
- a trailing
# …; avim:line; extra spaces.
Output and warnings are identical on all three for every form.
- a plain pair, and a plain pair followed by
-
git merge-treeagainst current main: clean. No mere-pr-review-watch inline comments. Local results in the description: corpus 894/894, VM 894 / 0, vm_check, gates, 4 unit files equal to main. These meet the merge criteria. Merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A follow-up to #257, from its review. The record is
loop/2026-11-25-stage10-magic-comment-forms.md; what follows is it.A follow-up to #257, from its review. #257 made the evaluator read
shareable_constant_valueonly as a comment's key, so that a comment mentioning the name (one of round 63's, in the Ruby compiler) was no magic comment. It took a key after a;anywhere, and the review found the case that gets wrong:ruby's rule
Read off ruby 4.0.10 for 25 comments, each before a constant written after a statement:
# key: value, blanks allowed around the colon and after the value.# shareable_constant_value: literal; foo: bar,# ... literal xand# frozen_string_literal: false; shareable_constant_value: literalset nothing;-*-: pairs separated by;or by blanks, a word with no:passed over (# -*- foo shareable_constant_value: literal -*-is read);# a-shareable_constant_value: literaland# foo shareable_constant_value: literalare none.The change
scv_valuereads the two forms so. All 25 comments give ruby's answer on both executions (the VM's main script is read by the evaluator's lexer too).And the warning of a late
frozen_string_literal. "'frozen_string_literal' is ignored after any tokens" was said for a plain comment that only started with the pair (# frozen_string_literal: true; shareable_constant_value: none), which ruby does not take for a magic comment and says nothing of; and it was not said for the emacs form (# -*- frozen_string_literal: true -*-), which ruby warns of.fsl_comment_textreads the same two forms. This was on main, on both executions.Corpus 823's file of magic comments has the forms.
Checked
Against ruby 4.0.10 (tools/ref_ruby.sh), built with Mere 9dec2ff6, on main 8b1b952 (and spot-checked on ec98015: corpus 823, the 25 comments, vm_check):
🤖 Generated with Claude Code