Skip to content

Commit

Permalink
Merge pull request #1167 from dpvc/fix-fractions
Browse files Browse the repository at this point in the history
Fix problem with implied multiplication in fraction context, and some typos. (#1166)
  • Loading branch information
drgrice1 authored Jan 7, 2025
2 parents f13935a + 07a3828 commit 352b286
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Parser/Function.pm
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ sub checkComplexOrMatrix {
my $self = shift;
my $op = $self->{params}[0];
return if ($self->checkArgCount(1));
$self->Error("Function '%s' requires a Complex or Matrixinput", $self->{name})
$self->Error("Function '%s' requires a Complex or Matrix input", $self->{name})
unless $op->isNumber || $op->type eq "Matrix" || $self->context->flag("allowBadFunctionInputs");
$self->{type} = $op->typeRef;
}
Expand Down
4 changes: 2 additions & 2 deletions macros/contexts/contextExtensions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ sub create {
#
# would attach the class context::Quaternions::BOP::add to the
# plus sign in our Quaternion setting. If the space operator (' ')
# in your list, and if the original context has it point to an
# operator that is NOT in your list, then that references operator
# is in your list, and if the original context has it point to an
# operator that is NOT in your list, then that referenced operator
# is redirected automatically to 'BOP::Space' in your base context
# package. In our case, we would want to include a definition for
# context::Quaternions::BOP::Space in order to cover that possibility.
Expand Down
13 changes: 10 additions & 3 deletions macros/contexts/contextFraction.pl
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ sub _check {
# This is not a mixed number, so convert to original class and do
# its _check
#
unless ($allowMixedNumbers
unless ($self->{bop} eq 'mixedNum'
&& $allowMixedNumbers
&& $self->extensionClassMatch($self->{lop}, 'INTEGER', 'MINUS')
&& !$self->{lop}{hadParens}
&& $self->extensionClassMatch($self->{rop}, 'FRACTION')
Expand All @@ -594,7 +595,13 @@ sub _check {
{
$self->{bop} = $self->{def}{string};
$self->{def} = $context->{operators}{ $self->{bop} };
return $self->mutate->_check;
my $class = $self->{def}{class};
if ($class eq ref($self) || $class =~ m/^context::Fraction::BOP::[Ss]pace$/) {
$self->mutate;
} else {
bless $self, $class;
}
return $self->_check;
}
$self->{type} = $context::Fraction::MIXED;
$self->Error("Mixed numbers are not allowed; you must use a pure fraction")
Expand All @@ -611,7 +618,7 @@ sub _check {
}

#
# For when the space operator's space property sends to an
# For when the space operator's string property sends to an
# operator we didn't otherwise subclass.
#
package context::Fraction::BOP::Space;
Expand Down

0 comments on commit 352b286

Please sign in to comment.