From 08476e24edf1997d993c2072c16a4c9983840270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20M=C3=AD=C5=A1ek?= Date: Tue, 8 Sep 2020 14:14:52 +0200 Subject: [PATCH] runtime conversion of enum type to PhpValue ref https://github.com/peachpiecompiler/peachpie/pull/845#issuecomment-688433177 --- src/Peachpie.Runtime/Dynamic/ConvertExpression.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Peachpie.Runtime/Dynamic/ConvertExpression.cs b/src/Peachpie.Runtime/Dynamic/ConvertExpression.cs index 1f93e6c353..4439577980 100644 --- a/src/Peachpie.Runtime/Dynamic/ConvertExpression.cs +++ b/src/Peachpie.Runtime/Dynamic/ConvertExpression.cs @@ -524,6 +524,12 @@ public static Expression BindToValue(Expression expr) if (source == typeof(uint)) return Expression.Call(typeof(PhpValue).GetMethod("Create", Cache.Types.Long), Expression.Convert(expr, typeof(long))); if (source == typeof(ulong)) return Expression.Call(typeof(PhpValue).GetMethod("Create", Cache.Types.UInt64), expr); + if (source.IsEnum) + { + // (PhpValue)(int)enum + return BindToValue(Expression.Convert(expr, source.GetEnumUnderlyingType())); + } + throw new NotImplementedException(source.FullName); } else if (