From 15bd6b038a8bf1dbed1fdb99fef395f9829c1bc5 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Fri, 26 Apr 2024 03:40:38 +0200 Subject: [PATCH] Fix bug --- hscript/Interp.hx | 8 +++++--- tests/src/tests/FinalCase.hx | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 29580c1..5ce4ae3 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -574,7 +574,7 @@ class Interp { var splitClassName:Array = c.split("."); if (splitClassName.length <= 0) return null; - + var varName:String = switch(mode) { case IAs(name): name; default: splitClassName[splitClassName.length-1]; @@ -601,6 +601,9 @@ class Interp { var newClassName:Array = splitClassName.copy(); importField = newClassName.pop(); + if(variables.exists(importField)) + return variables.get(importField); + importedClass = getClass(newClassName.join(".")); } @@ -611,8 +614,7 @@ class Interp { case Right(e): Tools.getEnum(e); }; if(importField != null) { - var v:Dynamic = null; - if(v == null) v = UnsafeReflect.getProperty(classOrEnum, importField); + var v:Dynamic = UnsafeReflect.getProperty(classOrEnum, importField); if(v == null) v = UnsafeReflect.field(classOrEnum, importField); if(v == null) diff --git a/tests/src/tests/FinalCase.hx b/tests/src/tests/FinalCase.hx index 38b391d..74acc3f 100644 --- a/tests/src/tests/FinalCase.hx +++ b/tests/src/tests/FinalCase.hx @@ -112,6 +112,12 @@ class FinalCase extends TestCase { Std.isOfType('', String); ", Std.isOfType('', String)); + assertEq(" + import Std.isOfType; + + isOfType('', String); + ", Std.isOfType('', String)); + assertEq(" import Math.round as F; F(2.9);", Math.round(2.9));