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

[compiler-v2] Generic TypeInfo verification broken #14205

Closed
wrwg opened this issue Aug 4, 2024 · 0 comments · Fixed by #14208
Closed

[compiler-v2] Generic TypeInfo verification broken #14205

wrwg opened this issue Aug 4, 2024 · 0 comments · Fixed by #14208
Labels
bug Something isn't working compiler-v2

Comments

@wrwg
Copy link
Contributor

wrwg commented Aug 4, 2024

Consider code like:

module app::m {
    use aptos_stdlib::type_info;
    
    fun generic_type_info_verification_target<A>(): type_info::TypeInfo {
       type_info::type_of<A>()
    }
    spec generic_type_info_verification_target {
        ensures result == generic_type_info_verification_target<A>();
    }
}

This yields in the following Boogie compilation error:

Move prover returns: [internal] boogie exited with compilation errors:
type_reflection.bpl(5059,26): Error: cannot refer to a global variable in this context: #0_info
type_reflection.bpl(5059,38): Error: cannot refer to a global variable in this context: #0_info
type_reflection.bpl(5059,50): Error: cannot refer to a global variable in this context: #0_info

This seems to be a bug in the new specification function inferrer shared between compiler v1 and v2. The native function type_info::type_of cannot be called from a specification function as it refers to type reflection state #0_info.

@wrwg wrwg added bug Something isn't working compiler-v2 labels Aug 4, 2024
wrwg added a commit that referenced this issue Aug 5, 2024
A specification function which uses `type_info::type_of<A>` where `A` is a type parameter implicitly depends on the Boogie global variable `#0_info`. However, that variable is not added to the Boogie function parameters. This PR adds logic to add additional parameters to specification functions capturing this dependency, if needed.

The issue seem to have been present since we introduced TypeInfo verification (so both in compiler v1 and v2) but hasen't surfaced yet as it appears that for framework verification, the problem is not hit.

Tested by a new case in prover `type_reflection.move` test.

Closes #14205
wrwg added a commit that referenced this issue Aug 5, 2024
A specification function which uses `type_info::type_of<A>` where `A` is a type parameter implicitly depends on the Boogie global variable `#0_info`. However, that variable is not added to the Boogie function parameters. This PR adds logic to add additional parameters to specification functions capturing this dependency, if needed.

The issue seem to have been present since we introduced TypeInfo verification (so both in compiler v1 and v2) but hasen't surfaced yet as it appears that for framework verification, the problem is not hit.

Tested by a new case in prover `type_reflection.move` test.

Closes #14205
@wrwg wrwg closed this as completed in 4d25322 Aug 5, 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 compiler-v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant