eclipse / n4js

Eclipse Public License 1.0
30 stars 27 forks source link

As a developer I want advanced static code analysis regarding implications between statements #2539

Open mmews-n4 opened 1 year ago

mmews-n4 commented 1 year ago

See the example below.

Example

function f(arg1: any+) {
    const val1 = arg1?.val; // implication 1: if val1 is truthy => arg1 is also truthy
    const val2 = val1?.prop; // implication 2: if val2 is truthy => val1 is also truthy
    const query = val2 ? {
        someProp: val1.prop // here we know based on implication 2 that val1 is truthy
    } : null;
    query;
}