diff --git a/go.mod b/go.mod index 37c4ccb42b6..90b48afd158 100644 --- a/go.mod +++ b/go.mod @@ -75,7 +75,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/grafana/sobek v0.0.0-20240711133011-3a280d337ef4 + github.com/grafana/sobek v0.0.0-20240808084414-f7ac208544fe github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index 051cd469f5b..ad8618840ff 100644 --- a/go.sum +++ b/go.sum @@ -82,8 +82,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/grafana/sobek v0.0.0-20240711133011-3a280d337ef4 h1:SKC348XXnCe9EIsAJ+xs5lzlZbzRsrGkqVbJ3451p3k= -github.com/grafana/sobek v0.0.0-20240711133011-3a280d337ef4/go.mod h1:tUEHKWaMrxFGrMgjeAH85OEceCGQiSl6a/6Wckj/Vf4= +github.com/grafana/sobek v0.0.0-20240808084414-f7ac208544fe h1:adA30lZ417BTZBJfuoBCjuHhM6SrcWQNbThi8g+c2Hs= +github.com/grafana/sobek v0.0.0-20240808084414-f7ac208544fe/go.mod h1:tUEHKWaMrxFGrMgjeAH85OEceCGQiSl6a/6Wckj/Vf4= github.com/grafana/xk6-browser v1.7.0 h1:Rip0st43EmzV37DFO2Gt7sXO4TTRM4g9wGMwBvVb67c= github.com/grafana/xk6-browser v1.7.0/go.mod h1:TNngUsbmV3I5NDVklGxjpAR2znEjYEsBtHQirGw8nAI= github.com/grafana/xk6-dashboard v0.7.5 h1:TcILyffT/Ea/XD7xG1jMA5lwtusOPRbEQsQDHmO30Mk= diff --git a/vendor/github.com/grafana/sobek/compiler.go b/vendor/github.com/grafana/sobek/compiler.go index 7fbd91ba4ea..eb863ba2dbb 100644 --- a/vendor/github.com/grafana/sobek/compiler.go +++ b/vendor/github.com/grafana/sobek/compiler.go @@ -1465,12 +1465,14 @@ func (c *compiler) compileLexicalDeclarations(list []ast.Statement, scopeDeclare c.createLexicalBindings(lex.LexicalDeclaration) } else if lex.ClassDeclaration != nil { declareScope() - if lex.IsDefault { - c.createLexicalIdBinding("default", false, int(lex.Idx0())-1) - } else { + if lex.ClassDeclaration.Class.Name != nil { cls := lex.ClassDeclaration c.createLexicalIdBinding(cls.Class.Name.Name, false, int(cls.Class.Name.Idx)-1) } + + if lex.IsDefault { + c.createLexicalIdBinding("default", false, int(lex.Idx0())-1) + } } else if lex.IsDefault { switch { case lex.HoistableDeclaration != nil: diff --git a/vendor/github.com/grafana/sobek/compiler_stmt.go b/vendor/github.com/grafana/sobek/compiler_stmt.go index 7d654d913ad..187f97516d2 100644 --- a/vendor/github.com/grafana/sobek/compiler_stmt.go +++ b/vendor/github.com/grafana/sobek/compiler_stmt.go @@ -792,7 +792,12 @@ func (c *compiler) compileExportDeclaration(expr *ast.ExportDeclaration) { case expr.ClassDeclaration != nil: cls := expr.ClassDeclaration if expr.IsDefault { - c.emitLexicalAssign("default", int(cls.Class.Class)-1, c.compileClassLiteral(cls.Class, false)) + if cls.Class.Name == nil { + c.emitLexicalAssign("default", int(cls.Class.Class)-1, c.compileClassLiteral(cls.Class, false)) + return + } + c.compileClassDeclaration(cls) + c.emitLexicalAssign("default", int(cls.Class.Class)-1, c.compileIdentifierExpression(cls.Class.Name)) } else { c.compileClassDeclaration(cls) } diff --git a/vendor/github.com/grafana/sobek/modules_sourcetext.go b/vendor/github.com/grafana/sobek/modules_sourcetext.go index 61e8a9abeb3..f39ec1fe067 100644 --- a/vendor/github.com/grafana/sobek/modules_sourcetext.go +++ b/vendor/github.com/grafana/sobek/modules_sourcetext.go @@ -301,9 +301,13 @@ func exportEntriesFromAst(declarations []*ast.ExportDeclaration) []exportEntry { } else if exportDeclaration.ClassDeclaration != nil { cls := exportDeclaration.ClassDeclaration.Class if exportDeclaration.IsDefault { + localName := "default" + if cls.Name != nil { + localName = cls.Name.Name.String() + } result = append(result, exportEntry{ exportName: "default", - localName: "default", + localName: localName, lex: true, offset: int(exportDeclaration.Idx0()), }) diff --git a/vendor/modules.txt b/vendor/modules.txt index f98eda16f94..f5dfa1b6a68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -163,7 +163,7 @@ github.com/google/uuid # github.com/gorilla/websocket v1.5.1 ## explicit; go 1.20 github.com/gorilla/websocket -# github.com/grafana/sobek v0.0.0-20240711133011-3a280d337ef4 +# github.com/grafana/sobek v0.0.0-20240808084414-f7ac208544fe ## explicit; go 1.20 github.com/grafana/sobek github.com/grafana/sobek/ast