Skip to content

Commit

Permalink
nullref fix & test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed May 3, 2024
1 parent 58e3ac5 commit 23b2ca2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ private void ResolveEquality(BoundBinaryEx cmpExpr)

bool isStrict = (cmpExpr.Operation == Operations.Identical || cmpExpr.Operation == Operations.NotIdentical);

if (isStrict && !cmpExpr.Left.CanHaveSideEffects() && !cmpExpr.Right.CanHaveSideEffects())
if (isStrict && Routine != null && !cmpExpr.Left.CanHaveSideEffects() && !cmpExpr.Right.CanHaveSideEffects())
{
// Always returns false if checked for strict equality and the operands are of different types (and vice versa for strict non-eq)
bool isPositive = (cmpExpr.Operation == Operations.Equal || cmpExpr.Operation == Operations.Identical);
Expand Down
10 changes: 10 additions & 0 deletions tests/constructs/class_consts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace constructs\class_consts;

class Test
{
const C = 1 !== 2 ? 'a' : 'b';
}

echo Test::C;
echo 'Done.';

0 comments on commit 23b2ca2

Please sign in to comment.