Dictu icon indicating copy to clipboard operation
Dictu copied to clipboard

Self referencing datatypes

Open Jason2605 opened this issue 4 years ago • 0 comments

Self referencing datatypes

Summary

If a datatype is self referencing, that in of itself is not an issue, however, if we attempt to do basic operations with the datatype you'll more than likely be hit with a segfault due to an infinite recursion.

Examples

Resolved

var x = [1];
x.push(x);
print(x); // Segfault
>>> const x = [1, 2];
>>> x.push(x);
>>> x == x; // Segfault
>>> import JSON;
>>> const x = [1, 2];
>>> x.push(x);
>>> JSON.stringify(x); // Segfault

Places tested

  • ~~Converting to string~~ Resolved by: https://github.com/dictu-lang/Dictu/pull/549
  • Equality
  • JSON

Jason2605 avatar Dec 08 '20 22:12 Jason2605