Skip to content

Commit 6770acc

Browse files
committed
Fix issue marijnz#2 by using Compile() instead of Evaluate() from the mono evaluator, allowing us to check if compilation failed vs if it merely yielded no object
1 parent aac98ab commit 6770acc

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Assets/UnityShell/Editor/Scripts/ShellEvaluator.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,17 @@ public object Evaluate(string command)
3131
command += ";";
3232
}
3333

34-
object outResult;
35-
bool isResultSet;
34+
var compilationResult = Evaluator.Compile(command);
35+
if (compilationResult == null)
36+
{
37+
return "Compilation failed for input: " + command;
38+
}
3639

37-
object result = Evaluator.Evaluate(command, out outResult, out isResultSet);
40+
object result = null;
41+
compilationResult(ref result);
3842

39-
if(isResultSet)
40-
{
41-
result = outResult;
42-
}
43-
else
44-
{
45-
result = "invalid input " + result;
46-
}
43+
if (result == null)
44+
result = "Executed command: " + command;
4745
return result;
4846
}
4947
}

0 commit comments

Comments
 (0)