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

Allow safe methods for getStaticValue #29

Closed
wants to merge 1 commit into from
Closed

Allow safe methods for getStaticValue #29

wants to merge 1 commit into from

Conversation

RunDevelopment
Copy link

This allows calls to safe instance methods of arrays and strings.

"Safe method" means that the method:

  1. Does not modify any of its parameters and the this argument.
  2. Is fast. The method must be efficient to execute.
  3. Does not consume much memory. The result of the method must consume an unreasonable amount of memory.
  4. Is deterministic and locale-independent.

Maybe more interesting than what safe methods are is what isn't a safe method. Here are a few example of non-safe methods:

  • Array#pop: This modifies the array.
  • Array#map and Array#flatMap: It is possible to create arbirarly large arrays using map + flat and flatMap (assuming user-defined function evaluation).
  • String#localeCompare: The result depends on the system the code is executed, so it's not deterministic.
  • String#{match,matchAll,replace,replaceAll,split}: RegExp execution isn't safe because it can take up to exponential time.
  • String#{matchAll,replace,replaceAll,split}: This be used to exponentially grow strings or arrays.

I also didn't include any of HTML-creating string methods (e.g "".big()).

@RunDevelopment RunDevelopment closed this by deleting the head repository Mar 16, 2023
@MichaelDeBoey
Copy link
Contributor

Hi @RunDevelopment! 👋

As mentioned in #40 (comment), we forked this repo into the @eslint-community GitHub organization & are maintaining it to not hold the wider community back anymore.

I would suggest to take a look at our fork & if you think this PR is still necessary/valuable, please create a PR on our fork & we'll look into merging it asap.

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

Successfully merging this pull request may close these issues.

2 participants