Comments (3)
The correct solution to this is "don't do that." but leaving up for @kr to close at will.
from diff.
Yeah, this is a recursive transform, which is fine; the problem is it specifies an unbounded recursion. The transform says "convert each string into a slice of strings to be compared". The diff function then traverses the slice, and needs to compare the contents, which leads to the transform being applied again on the string inside the slice, which yields another slice of strings. This process repeats indefinitely.
There wouldn't be a problem if at some point this transform returned a different type or an empty slice. It eventually needs to return something that doesn't result in itself being applied again at a later step. More precisely, it needs to (eventually) return a value that doesn't contain a string
value anywhere, since string
is the type it accepts as input.
There's no easy way for diff to guard against this problem, since recursive transforms in general are ok. They just need to bottom out somewhere. This is analogous to a programming language allowing recursive functions. There's no good way to statically prevent unbounded recursion; the best you can do is report an error at runtime if the stack gets too large. That's what we do too.
from diff.
Having said all that, it would be worth mentioning this in the docs somewhere.
from diff.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff.