Skip to content

Fix Perl modulus semantics in dynamically autoloaded methods #1311

Description

@fglock

DateTime::Lite pure-Perl fallback returns negative local_day_of_week

DateTime::Lite v0.8.0 fails one upstream test under PerlOnJava:

t/11.accessors.t — local_day_of_week() in 1..7

The same distribution passes completely under system Perl (346/346 tests).
PerlOnJava reproduces the failure on both the JVM and interpreter backends,
using DateTime::Lite's pure-Perl fallback because its XS code is unavailable.

Observed behavior:

my $dt = DateTime::Lite->now;
my $x = $dt->day_of_week - $dt->{locale}->first_day_of_week;
# x = -5, and x % 7 returns 2
# but $dt->local_day_of_week returns -4

The dynamically autoloaded implementation is:

return( 1 + ( ( $self->day_of_week - $self->{locale}->first_day_of_week ) % 7 ) );

This suggests that the dynamically compiled/autoloaded method is applying Java
remainder semantics (-5 % 7 == -5) instead of Perl modulus semantics
(-5 % 7 == 2). A direct top-level PerlOnJava expression returns the correct
value, so the discrepancy appears specific to the dynamic/autoloaded execution
path.

Failure classification: confirmed PerlOnJava internal bug, affecting both
backends. CPAN compatibility run: 20260908-190650-31465.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendJVM interpreter or execution-backend behaviorarea:parserParsing compilation AST and eval behaviorarea:runtimeCore Perl runtime semanticsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions