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

Function.prototyp.toString only returns a fixed [native code] string #3780

Open
FredrikNoren opened this issue Apr 2, 2024 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@FredrikNoren
Copy link

ECMASCript feature
Function.prototyp.toString returns the actual javascript implementation in v8. ECMAScript specification

Example code

let f = () => 1 + 1;
console.log(f.toString());

The expected output is () => 1 + 1.

@FredrikNoren FredrikNoren added the enhancement New feature or request label Apr 2, 2024
@Nikita-str
Copy link
Contributor

Nikita-str commented Sep 29, 2024

Is it ok to add in Cursor a fields that will collect source_text: Vec<u32> when callable is parsing (if nested callable is parsing then it just will take slice of it) to solve the issue?
Or maybe do it at some lower layer(on BufferedLexer or Lexer) to pass less params?

Is it acceptable to add this fields into Interner? It seems like not fully fit the meaning of Interner, but it looks very convenient because we have &mut Interner in Tokenizer::lex.

@jedel1043
Copy link
Member

Yeah, those changes sound good. I would say that on the AST side it would be the Module and the Script the ones holding the script source, and the rest of nodes would just have a span to index that.

@Nikita-str
Copy link
Contributor

Hmm, do I understand you correctly: collect ALL the source code, and use it whenever we need some part of initial code (e.g. name of functions, string literals, and function source codes)?

Or should it be done only for source codes of functions (it's what I try to do now)?

@jedel1043
Copy link
Member

All the code probably, because we're planning to use that to improve the error messages.

Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 30, 2024
Nikita-str added a commit to Nikita-str/boa that referenced this issue Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants