From dd1a836903ea52c7f6a52a01ac4ccc27a63006f2 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 22 May 2022 14:02:01 +0200 Subject: [PATCH] interp: do not try to interpret past task.Pause() For context, see: https://github.com/tinygo-org/tinygo/pull/2863#issuecomment-1133875237 Basically, testdata/goroutine.go was doing `time.Sleep()` inside an init function which broke because doing that from a non-goroutine is not allowed. However, we never hit this bug because of https://github.com/tinygo-org/tinygo/issues/2842 (I didn't investigate exactly why). --- interp/interpreter.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interp/interpreter.go b/interp/interpreter.go index 1044a2c5..0f2355a6 100644 --- a/interp/interpreter.go +++ b/interp/interpreter.go @@ -219,6 +219,9 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent if err != nil { return nil, mem, err } + case callFn.name == "internal/task.Pause": + // Task scheduling isn't possible at compile time. + return nil, mem, r.errorAt(inst, errUnsupportedRuntimeInst) case callFn.name == "runtime.nanotime" && r.pkgName == "time": // The time package contains a call to runtime.nanotime. // This appears to be to work around a limitation in Windows