Open szuend opened 1 day ago
The generic kinds were meant to be defined by the language instead of by the spec. Eg, we left a Note: JavaScript implementations should use 'global', 'class', 'function', and 'block'.
, but C++ might choose different names.
Given the following authored code:
And the generated code:
The scopes proposal would put
(A)
as the definition of(R1)
and(B)
as the definition of(R2)
.The call-site of
x()
would produce a stack frame withf 2:5
. With that position we find the generated range(R2)
and the corresponding original scope of(B)
.(B)
doesn't have aname
so we can't say what the original function name was.The right thing to do, is walk the original scope chain outwards until we find an original scope that's "callable" (in this case
(R1)
and get thename
from there, but "kind" is an arbitrary string, so we don't know how far to walk.There are a couple of solutions how we can fix this:
Revert the change that made
kind
into an arbitrary text and keep a pre-defined list ofglobal
,function
andblock
. We can still add akindLabel
so generators can label original scopes more appropriately based on the source language.Leave "kind" as-is, but add a "isCallable"/"isFunction"/"showsUpInStackTrace" flag on original scopes.
Require that anything callable has "kind" of
'function'
. This seems very brittle to me and I'd prefer either a flag or a fixed original scope type.Note that we can't just simply walk the original scope chain outwards until we find something with a
name
. Generators could emit scopes for classes, modules or namespaces with names that don't make sense to show in a stack trace.