Skip to content

Error with equaltiy comparisions with Fraction context after changing context #1337

@somiaj

Description

@somiaj

Consider the following example problem.

DOCUMENT();
loadMacros(qw(PGstandard.pl contextFraction.pl PGML.pl));

Context('Fraction')->variables->are(c => 'Real');
$x = Formula("4c");
Context('Numeric');
$test = $x == 0 ? 'Yes' : 'No';
TEXT($test);
ENDDOCUMENT();

This problem produces the following error on 2.20.

ERRORS from evaluating PG file:
Can't call method "can" on an undefined value at line 395 of [PG]/macros/contexts/contextExtensions.pl
   from within context::Extensions::Super::super called at line 784 of [PG]/macros/contexts/contextFraction.pl
   from within context::Fraction::Parser::Number::new called at line 629 of [PG]/lib/Parser.pm
   from within Parser::Num called at line 159 of [PG]/lib/Parser.pm
   from within Parser::parse called at line 54 of [PG]/lib/Parser.pm
   from within Parser::new called at line 19 of [PG]/lib/Value/Formula.pm
   from within Value::Formula::new called at line 173 of [PG]/lib/Value/Formula.pm
   from within Value::Formula::compare called at line 851 of [PG]/lib/Value.pm
   from within Value::binOp called at line 865 of [PG]/lib/Value.pm
   from within Value::_compare called at line 7 of undefined

Removing the Context('Numeric') line causes the problem to work correctly. I caught this in a problem in which I changed the context to Matrix, so it seems the issue arises when changing the current context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions