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

panic: Scope location 47 must be greater than 84 #2

Open
programmeruser2 opened this issue Apr 29, 2021 · 4 comments
Open

panic: Scope location 47 must be greater than 84 #2

programmeruser2 opened this issue Apr 29, 2021 · 4 comments

Comments

@programmeruser2
Copy link

I was working on my discord bot on repl.it, and it appears that upm invoked this package which apparently has a bug.
Here are the logs:

 panic: Scope location 47 must be greater than 84 [recovered]
    panic: Scope location 47 must be greater than 84

goroutine 19 [running]:
github.com/amasad/esparse/parser.Parse.func1(0xc000103e58)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7827 +0x6a
panic(0x883dc0, 0xc000198030)
    /usr/lib/go-1.15/src/runtime/panic.go:969 +0x1b9
github.com/amasad/esparse/parser.(*parser).pushScopeForParsePass(0xc0001a6000, 0x2, 0x2f, 0x2)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:272 +0x39f
github.com/amasad/esparse/parser.(*parser).parseParenExpr(0xc0001a6000, 0x2f, 0x0, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1759 +0x6ab
github.com/amasad/esparse/parser.(*parser).parsePrefix(0xc0001a6000, 0x3, 0x0, 0xc000000000, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1915 +0x14e9
github.com/amasad/esparse/parser.(*parser).parseExpr(0xc0001a6000, 0x3, 0x82231101, 0xc0000d1158, 0x778474)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2435 +0x45
github.com/amasad/esparse/parser.(*parser).parseSuffix(0xc0001a6000, 0x1e, 0x10d14a0, 0xc000180270, 0x0, 0x0, 0x8debc0, 0xc0001a6001, 0xc000194120)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2872 +0x3825
github.com/amasad/esparse/parser.(*parser).parseExpr(0xc0001a6000, 0x0, 0x1, 0x1, 0x1)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2435 +0x85
github.com/amasad/esparse/parser.(*parser).parseStmt(0xc0001a6000, 0x101, 0x0, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4592 +0x110
github.com/amasad/esparse/parser.(*parser).parseStmtsUpTo(0xc0001a6000, 0x0, 0x101, 0x27, 0xc000196120, 0x27)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4834 +0xa8
github.com/amasad/esparse/parser.Parse(0xc000182060, 0x1, 0xc000196120, 0x27, 0xc000196120, 0x27, 0xc0001a2000, 0xdf, 0x1, 0x0, ...)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7851 +0x1d0
github.com/replit/upm/internal/backends/nodejs.parseFile(0x1, 0xc000196120, 0x27, 0xc000196120, 0x27, 0xc0001a2000, 0xdf, 0xc000182000)
    /upm/internal/backends/nodejs/grab.go:86 +0x158
created by github.com/replit/upm/internal/backends/nodejs.guessBareImports.func1
    /upm/internal/backends/nodejs/grab.go:136 +0x431

panic: Scope location 47 must be greater than 84 [recovered]
    panic: Scope location 47 must be greater than 84

goroutine 7 [running]:
github.com/amasad/esparse/parser.Parse.func1(0xc0000f9e58)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7827 +0x6a
panic(0x883dc0, 0xc0000576c0)
    /usr/lib/go-1.15/src/runtime/panic.go:969 +0x1b9
github.com/amasad/esparse/parser.(*parser).pushScopeForParsePass(0xc0000b6580, 0x2, 0x2f, 0x2)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:272 +0x39f
github.com/amasad/esparse/parser.(*parser).parseParenExpr(0xc0000b6580, 0x2f, 0x0, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1759 +0x6ab
github.com/amasad/esparse/parser.(*parser).parsePrefix(0xc0000b6580, 0x3, 0x0, 0xc000000000, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1915 +0x14e9
github.com/amasad/esparse/parser.(*parser).parseExpr(0xc0000b6580, 0x3, 0xec6d00bb, 0xc0000cd158, 0x778474)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2435 +0x45
github.com/amasad/esparse/parser.(*parser).parseSuffix(0xc0000b6580, 0x1e, 0x10d14a0, 0xc0001285d0, 0x0, 0x0, 0x8debc0, 0xc0000b6501, 0xc00000f100)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2872 +0x3825
github.com/amasad/esparse/parser.(*parser).parseExpr(0xc0000b6580, 0x0, 0x1, 0x1, 0x1)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2435 +0x85
github.com/amasad/esparse/parser.(*parser).parseStmt(0xc0000b6580, 0x101, 0x0, 0x0, 0x0)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4592 +0x110
github.com/amasad/esparse/parser.(*parser).parseStmtsUpTo(0xc0000b6580, 0x0, 0x101, 0x27, 0xc00002c180, 0x27)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4834 +0xa8
github.com/amasad/esparse/parser.Parse(0xc000026240, 0x1, 0xc00002c180, 0x27, 0xc00002c180, 0x27, 0xc0000b0380, 0xdf, 0x1, 0x0, ...)
    /root/go/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7851 +0x1d0
github.com/replit/upm/internal/backends/nodejs.parseFile(0x1, 0xc00002c180, 0x27, 0xc00002c180, 0x27, 0xc0000b0380, 0xdf, 0xc0000261e0)
    /upm/internal/backends/nodejs/grab.go:86 +0x158
created by github.com/replit/upm/internal/backends/nodejs.guessBareImports.func1
    /upm/internal/backends/nodejs/grab.go:136 +0x431
@amasad
Copy link
Owner

amasad commented May 4, 2021

Interesting, do you know which package is causing this?

@Obaida-Albaroudi
Copy link

@programmeruser2 Hi! Just looked into this for you and it looks like there was an issue with the .replit file. If you add a closing quotation at the end of the run command it should work. I attached a screenshot of how I got my fork to work as well as my forked repl.

My repl:

Screen Shot 2021-05-04 at 12 15 40 PM

@programmeruser2
Copy link
Author

programmeruser2 commented May 5, 2021

@Obaida-Albaroudi Yes, it does work if you tell the packager to ignore the current directory, which is functionally equivalent to turning it off. The bug still persists if you don't.

@cherryblossom000
Copy link

cherryblossom000 commented Jul 20, 2021

I'm having the same error, but I'm not sure if it's the same bug.

I've narrowed it down to a minimal example (playground):

package main

import (
	"github.com/amasad/esparse/logging"
	"github.com/amasad/esparse/parser"
)

func main() {
	logger, _ := logging.NewStderrLog(logging.StderrOptions{})
	path := "file.js"
	parser.Parse(logger, logging.Source{
		Index:        0,
		AbsolutePath: path,
		PrettyPath:   path,
		Contents:     `(a = () => {}) => {}`,
	}, parser.ParseOptions{})
}

This outputs:

panic: Scope location 0 must be greater than 5 [recovered]
	panic: Scope location 0 must be greater than 5

goroutine 1 [running]:
github.com/amasad/esparse/parser.Parse.func1(0xc000191f38)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7827 +0x6b
panic(0x51bd60, 0xc0000102c0)
	/usr/local/go-faketime/src/runtime/panic.go:965 +0x1b9
github.com/amasad/esparse/parser.(*parser).pushScopeForParsePass(0xc000188000, 0x2, 0x0, 0x0)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:272 +0x39f
github.com/amasad/esparse/parser.(*parser).parseParenExpr(0xc000188000, 0x0, 0x0, 0x0, 0x0)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1759 +0x6c5
github.com/amasad/esparse/parser.(*parser).parsePrefix(0xc000188000, 0x0, 0x0, 0x7f7500000000, 0x0, 0x0)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:1915 +0x15cf
github.com/amasad/esparse/parser.(*parser).parseExpr(0xc000188000, 0x0, 0x400, 0x30, 0x7f7569803e00)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:2435 +0x45
github.com/amasad/esparse/parser.(*parser).parseStmt(0xc000188000, 0x101, 0x0, 0x0, 0x0)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4592 +0x110
github.com/amasad/esparse/parser.(*parser).parseStmtsUpTo(0xc000188000, 0x0, 0x101, 0x7, 0x541f14, 0x7)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:4834 +0xa6
github.com/amasad/esparse/parser.Parse(0xc0000620c0, 0x0, 0x541f14, 0x7, 0x541f14, 0x7, 0x5445b8, 0x14, 0x0, 0x0, ...)
	/tmp/gopath258687768/pkg/mod/github.com/amasad/[email protected]/parser/parser.go:7851 +0x1d0
main.main()
	/tmp/sandbox989750109/prog.go:11 +0x125

Program exited: status 2.

I think it's having trouble with an arrow function as the default parameter of another arrow function.

I would try and fix this and open a PR, but I have absolutely no experience with Go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants