Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@swernli
Copy link
Contributor

@swernli swernli commented Feb 24, 2021

This fixes an issue where body intrinsic callables would appear twice in monomorphized results by pruning the list of concretized callables based on intrinsic settings.

This fixes an issue where `body intrinsic` callables would appear twice in monomorphized results by pruning the list of concretized callables based on intrinsic settings.
@swernli
Copy link
Contributor Author

swernli commented Feb 24, 2021

@ScottCarda-MS I could use some tips on testing this change. I was able to manually verify from a built package that it eliminates the issue, but perhaps there are tests I can add in the runtime repo once this is merged?

Copy link
Contributor

@bettinaheim bettinaheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for finding this!

var filter = new ResolveGenerics(callables.ToLookup(res => res.FullName.Namespace), intrinsicCallableSet, keepAllIntrinsics);
var filter = new ResolveGenerics(
callables
.Where(call => !keepAllIntrinsics || !intrinsicCallableSet.Contains(call.FullName))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could pull this out of the iteration.

@ScottCarda-MS
Copy link
Contributor

@swernli For testing, there are some Monomorphization test cases found here: https://github.com/microsoft/qsharp-compiler/blob/main/src/QsCompiler/Tests.Compiler/TestCases/LinkingTests/Monomorphization.qs
and the associated tests for these are found here: https://github.com/microsoft/qsharp-compiler/blob/main/src/QsCompiler/Tests.Compiler/LinkingTests.fs#L244

You could add a test case that defines a custom intrinsic, and then uses this intrinsic in the entry point. The testing logic would then verify that there is exactly the expected operations in the syntax tree after Monomorphization is run (it is run for all such test cases). I believe even just running a Signatures test on this would have that effect. We can discuss that more offline if you want to know more about how to do that.

@swernli
Copy link
Contributor Author

swernli commented Feb 24, 2021

@ScottCarda-MS Thanks, that's perfect! Don't know how I missed that in my searches...

@swernli swernli enabled auto-merge (squash) February 24, 2021 23:56
@swernli swernli merged commit d2f3de6 into main Feb 25, 2021
@swernli swernli deleted the swernli/duplicate-fix branch February 3, 2022 05:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants