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

TS Add operation is not solved into path constraints properly #216

Open
zishkaz opened this issue Oct 3, 2024 · 0 comments
Open

TS Add operation is not solved into path constraints properly #216

zishkaz opened this issue Oct 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zishkaz
Copy link
Collaborator

zishkaz commented Oct 3, 2024

Bug Description

Consider this test (remake of argWithArg from resources/samples/TypeCoercion.ts):

plus(a: number, b: number): number {
      if (a + b == 10.0) {
          return 1
      } else {
          return 0
      }
}

In current state, USVM TS for path that retuns 1 will return a model containing a and b, sum of which is not 10.0. This model contradicts path constraints.

Extracted values:
	[Double(value=10.0), Double(value=2.578975581576977E-231), Double(value=1.0)] // false model, 10.0 + 2.57 != 10.0
	[Double(value=0.0), Double(value=0.0), Double(value=0.0)]

Nevertheless, correct SAT-solver expression is generated for condition a + b == 10.0:
KEqExpr(KFpAddExpr(a, b), KFp64(10.0)))

Research

Functional comparison with USVM Java is difficult because the same function plus above written in Java won't produce equality operation in if statement. Instead, it will use JacoDB jvm-specific Cmpl operator in three-address code. Cmpl has different semantics from true/false equality and does not have any alternatives in TypeScript three-address code.

USVM TS machine code examination didn't yield any results since generated path constraints are correct.

Possible USVM core error, or complex symbolic expressions' misuse.

@zishkaz zishkaz added the bug Something isn't working label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant