Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/actions/capiext/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: rubyspec C-API extensions

inputs:
builddir:
required: false
default: '.'
make:
required: false
default: 'make -s'

outputs:
key:
value: >-
${{
!steps.restore.outputs.cache-hit &&
github.ref == 'refs/heads/master' &&
steps.config.outputs.key
}}

runs:
using: composite

steps:
- id: config
shell: bash
run: |
eval $(grep -e '^arch *=' -e '^ruby_version *=' -e '^DLEXT *=' Makefile |
sed 's/ *= */=/')
key=capiexts-${arch}-${ruby_version}
echo key=$key >> $GITHUB_OUTPUT
echo DLEXT=$DLEXT >> $GITHUB_OUTPUT
working-directory: ${{ inputs.builddir }}

- name: CAPI extensions cache
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache
with:
path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/
key: ${{ steps.config.outputs.key }}

- name: Run test-spec with previous CAPI extension binaries
shell: bash
run: |
touch spec/ruby/optional/capi/ext/*.$DLEXT
[ ! -f spec/ruby/optional/capi/ext/\*.$DLEXT ]
${{ inputs.make }} SPECOPTS=optional/capi test-spec
env:
DLEXT: ${{ steps.config.outputs.DLEXT }}
working-directory: ${{ inputs.builddir }}
if: ${{ steps.cache.outputs.cache-hit }}
9 changes: 9 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
os: macos-14
- test_task: check
os: macos-15
capi_check: capi
- test_task: check
os: macos-13
fail-fast: false
Expand Down Expand Up @@ -159,6 +160,14 @@ jobs:
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- name: CAPI extensions
uses: ./.github/actions/capiext
with:
builddir: build
env:
RUBY_TESTOPTS: '-v --tty=no'
if: ${{ matrix.capi_check }}

- uses: ./.github/actions/slack
with:
label: ${{ matrix.os }} / ${{ matrix.test_task }}
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- test_task: test-bundled-gems
- test_task: check
os: ubuntu-24.04
capi_check: capi
# ubuntu-24.04-arm jobs don't start on ruby/ruby as of 2025-09-04
#- test_task: check
# os: ubuntu-24.04-arm
Expand Down Expand Up @@ -152,6 +153,15 @@ jobs:
DESTDIR=${RUNNER_TEMP-${TMPDIR-/tmp}}/installed
$SETARCH make test-pc "DESTDIR=$DESTDIR"

- name: CAPI extensions
uses: ./.github/actions/capiext
with:
builddir: build
make: '$SETARCH make'
env:
RUBY_TESTOPTS: '-v --tty=no'
if: ${{ matrix.capi_check }}

- uses: ./.github/actions/slack
with:
label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}
Expand Down
4 changes: 2 additions & 2 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ total_final_slots_count(rb_objspace_t *objspace)
#endif

struct RZombie {
struct RBasic basic;
VALUE flags;
VALUE next;
void (*dfree)(void *);
void *data;
Expand Down Expand Up @@ -2586,7 +2586,7 @@ rb_gc_impl_make_zombie(void *objspace_ptr, VALUE obj, void (*dfree)(void *), voi
rb_objspace_t *objspace = objspace_ptr;

struct RZombie *zombie = RZOMBIE(obj);
zombie->basic.flags = T_ZOMBIE | (zombie->basic.flags & ZOMBIE_OBJ_KEPT_FLAGS);
zombie->flags = T_ZOMBIE | (zombie->flags & ZOMBIE_OBJ_KEPT_FLAGS);
zombie->dfree = dfree;
zombie->data = data;
VALUE prev, next = heap_pages_deferred_final;
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/translation/parser/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Lexer
# The following token types are listed as those classified as `tLPAREN`.
LPAREN_CONVERSION_TOKEN_TYPES = Set.new([
:kBREAK, :tCARET, :kCASE, :tDIVIDE, :kFOR, :kIF, :kNEXT, :kRETURN, :kUNTIL, :kWHILE, :tAMPER, :tANDOP, :tBANG, :tCOMMA, :tDOT2, :tDOT3,
:tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS
:tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS, :tLCURLY
])

# Types of tokens that are allowed to continue a method call with comments in-between.
Expand Down
20 changes: 10 additions & 10 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -18570,17 +18570,11 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
call->closing_loc = arguments.closing_loc;
call->block = arguments.block;

if (arguments.block != NULL) {
call->base.location.end = arguments.block->location.end;
} else if (arguments.closing_loc.start == NULL) {
if (arguments.arguments != NULL) {
call->base.location.end = arguments.arguments->base.location.end;
} else {
call->base.location.end = call->message_loc.end;
}
} else {
call->base.location.end = arguments.closing_loc.end;
const uint8_t *end = pm_arguments_end(&arguments);
if (!end) {
end = call->message_loc.end;
}
call->base.location.end = end;
}
} else {
// Otherwise, we know the identifier is in the local table. This
Expand Down Expand Up @@ -19108,7 +19102,13 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
pm_binding_power_t binding_power = pm_binding_powers[parser->current.type].left;

if (binding_power == PM_BINDING_POWER_UNSET || binding_power >= PM_BINDING_POWER_RANGE) {
pm_token_t next = parser->current;
parse_arguments(parser, &arguments, false, PM_TOKEN_EOF, (uint16_t) (depth + 1));

// Reject `foo && return bar`.
if (!accepts_command_call && arguments.arguments != NULL) {
PM_PARSER_ERR_TOKEN_FORMAT(parser, next, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_type_human(next.type));
}
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/prism/errors/command_calls_32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
foo && return bar
^~~ unexpected local variable or method, expecting end-of-input

tap { foo && break bar }
^~~ unexpected local variable or method, expecting end-of-input

tap { foo && next bar }
^~~ unexpected local variable or method, expecting end-of-input

foo && return()
^ unexpected '(', expecting end-of-input

foo && return(bar)
^ unexpected '(', expecting end-of-input

foo && return(bar, baz)
^~~~~~~~~~ unexpected write target
^ unexpected '(', expecting end-of-input

4 changes: 4 additions & 0 deletions test/prism/fixtures/break.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ tap { break() }

tap { break(1) }

tap { (break 1) }

tap { foo && (break 1) }

foo { break 42 } == 42

foo { |a| break } == 42
Expand Down
4 changes: 4 additions & 0 deletions test/prism/fixtures/next.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ tap { next
tap { next() }

tap { next(1) }

tap { (next 1) }

tap { foo && (next 1) }
3 changes: 3 additions & 0 deletions test/prism/fixtures/return.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ return()

return(1)

(return 1)

foo && (return 1)