diff --git a/src/analyzer/expr/binop/arithmetic_analyzer.rs b/src/analyzer/expr/binop/arithmetic_analyzer.rs index 4f1cd4f6..a774a5f4 100644 --- a/src/analyzer/expr/binop/arithmetic_analyzer.rs +++ b/src/analyzer/expr/binop/arithmetic_analyzer.rs @@ -105,7 +105,7 @@ pub(crate) fn analyze<'expr: 'tast, 'tast>( .. } = &e1_type_atomic { - e1_type_atomic = e1_type_atomic.clone(); + e1_type_atomic = (**constraint).clone(); } if let TAtomic::TFalse = e1_type_atomic { @@ -145,7 +145,7 @@ pub(crate) fn analyze<'expr: 'tast, 'tast>( .. } = &e2_type_atomic { - e2_type_atomic = e2_type_atomic.clone(); + e2_type_atomic = (**constraint).clone(); } if let TAtomic::TFalse = e2_type_atomic { diff --git a/tests/inference/Constant/classConstantValueOfEnum/class_def.hack b/tests/inference/Constant/classConstantValueOfEnum/class_def.hack new file mode 100644 index 00000000..5ea17a43 --- /dev/null +++ b/tests/inference/Constant/classConstantValueOfEnum/class_def.hack @@ -0,0 +1,8 @@ +enum Foo: int as int { + BAR = 1; + BAZ = 2; +} + +final class A { + const int FOO = Foo::BAR; +} \ No newline at end of file diff --git a/tests/inference/Constant/classConstantValueOfEnum/input.hack b/tests/inference/Constant/classConstantValueOfEnum/input.hack new file mode 100644 index 00000000..6be1e2e5 --- /dev/null +++ b/tests/inference/Constant/classConstantValueOfEnum/input.hack @@ -0,0 +1,3 @@ +function add(int $i): int { + return A::FOO + 1; +} \ No newline at end of file