question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

predicate literals lead to undecidable problem in static analysis

See original GitHub issue

predicates may be used in an interface

interface Integer (number) => number === parseInt(number, 10);

They introduce dependent types:

a dependent type is a type whose definition depends on a value […] Dependent types add complexity to a type system. Deciding the equality of dependent types in a program may require computations. If arbitrary values are allowed in dependent types, then deciding type equality may involve deciding whether two arbitrary programs produce the same result; hence type checking may become undecidable.

Furthermore, Integer is rather a type than a characteristic of a value. What is the type of the result c in

var c = a + b; // a: Integer, b: Integer

Catchy question! You get an error. + is not defined for Integer and we do not know that Integer is a Number. We need to add the type Number to the parameter of the predicate to provide this information:

interface Integer (number: Number) => number === parseInt(number, 10);

What is the type of c now? Since + is not defined for Integer but for Number, c is of type Number. If we like to pass c to a function that takes an Integer we have to do a manually type check before. Otherwise, we cann’t do static type analysis in a safe way.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
maiermiccommented, May 1, 2016

@ericelliott late answer to your question

I’m pretty sure the same dependent type problem exists with regular expression literals, right

Yes, indeed!

0reactions
maiermiccommented, Feb 3, 2016

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · ericelliott/rtype - GitHub
List possible literal types, such as null , undefined , obj literals... ... predicate literals lead to undecidable problem in static analysis ready....
Read more >
Improving static analyses of C programs with conditional ...
This paper presents a generic abstract interpretation based framework to enhance the precision of such analyses on join points. It relies on ...
Read more >
Static Program Analysis - Department of Computer Science
Static program analysis is the art of reasoning about the behavior of computer programs without actually running them.
Read more >
On Manufacturing Resilient Opaque Constructs Against Static ...
Precise flow-sensitive alias analysis is known to be undecidable in general [23], but this formulation is only known to be \mathcal {NP}-hard in ......
Read more >
Predicate Abstraction for Software Verification - CiteSeerX
... due to the test coverage problem. Static analysis techniques could potentially ... impossible in general since the problem is undecidable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found