Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid crashing the engine when JS debugger statement is used #3547

Merged
merged 7 commits into from
Jun 25, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.enso.interpreter.runtime.data.text.Text;
import org.enso.interpreter.runtime.scope.FramePointer;
import org.enso.interpreter.runtime.state.Stateful;
import org.enso.polyglot.LanguageInfo;
import org.enso.polyglot.debugger.DebugServerInfo;
import org.graalvm.options.OptionDescriptor;
import org.graalvm.options.OptionDescriptors;
Expand All @@ -38,8 +39,6 @@
/** The Instrument implementation for the interactive debugger REPL. */
@TruffleInstrument.Registration(id = DebugServerInfo.INSTRUMENT_NAME)
public class ReplDebuggerInstrument extends TruffleInstrument {
private Env env;

/**
* Called by Truffle when this instrument is installed.
*
Expand All @@ -48,8 +47,10 @@ public class ReplDebuggerInstrument extends TruffleInstrument {
@Override
protected void onCreate(Env env) {
SourceSectionFilter filter =
SourceSectionFilter.newBuilder().tagIs(DebuggerTags.AlwaysHalt.class).build();
this.env = env;
SourceSectionFilter.newBuilder()
.mimeTypeIs(LanguageInfo.MIME_TYPE)
.tagIs(DebuggerTags.AlwaysHalt.class)
.build();

DebuggerMessageHandler handler = new DebuggerMessageHandler();
try {
Expand Down
6 changes: 6 additions & 0 deletions test/Tests/src/Semantic/Js_Interop_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import Standard.Test
foreign js my_method a b = """
return a + b;

foreign js debug = """
debugger;

type My_Type
type My_Type a b

Expand Down Expand Up @@ -179,4 +182,7 @@ spec = Test.group "Polyglot JS" <|
error = Error.throw 42
here.my_method error 0 . should_fail_with Integer

Test.specify "allow use of JavaScript debugger statement" <|
here.debug

main = Test.Suite.run_main here.spec