Skip to content

Commit

Permalink
address 'address' issue openwebwork#872
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc authored and Alex-Jordan committed Dec 2, 2023
1 parent 9bc48db commit c8a9125
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/Value.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,12 @@ sub inContext { my $self = shift; $self->context(@_); $self }

#############################################################

#
#
# The address of a Value object (actually ANY perl value).
# Use this to compare two objects to see of they are
# the same object (avoids automatic stringification).
#
sub address { oct(sprintf("0x%p", shift)) }
sub address { Scalar::Util::refaddr(shift) }

sub isBlessed { (Scalar::Util::blessed(shift) // '') ne "" }
sub blessedClass { Scalar::Util::blessed(shift) }
Expand Down
4 changes: 2 additions & 2 deletions macros/answers/answerHints.pl
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ sub Compare {
$ans->{ans_message} = $ans->{error_message} = "";
$ans->{score} = 0;

if (sprintf("%p", $self) ne sprintf("%p", $ans->{correct_value})) {
if ($self->address != $ans->{correct_value}->address) {
$ans->{correct_ans} = $self->string;
$ans->{correct_value} = $self;
$ans->{correct_formula} = Value->Package("Formula")->new($self);
}
if (sprintf("%p", $other) ne sprintf("%p", $ans->{student_value})) {
if ($other->address != $ans->{student_value}->address) {
$ans->{student_ans} = $other->string;
$ans->{student_value} = $other;
$ans->{student_formula} = Value->Package("Formula")->new($other);
Expand Down

0 comments on commit c8a9125

Please sign in to comment.