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

Use in-parameter operator from different assembly #23689

Closed
ufcpp opened this issue Dec 10, 2017 · 3 comments
Closed

Use in-parameter operator from different assembly #23689

ufcpp opened this issue Dec 10, 2017 · 3 comments
Assignees
Milestone

Comments

@ufcpp
Copy link
Contributor

ufcpp commented Dec 10, 2017

Version Used:

VS 15.5.0

Steps to Reproduce:

https://github.com/ufcpp/UfcppSample/tree/master/Demo/2017/InOperatorDifferentAssemly

  1. Write a struct with in-parameter operator in an assebmly
    public struct DifferentAssembly
    {
        ....
        // by-val
        public static DifferentAssembly operator +(DifferentAssembly a, DifferentAssembly b)
        ....

        // by-ref-readonly
        public static DifferentAssembly operator *(in DifferentAssembly a, in DifferentAssembly b)
        ....
    }
  1. Use it from another assembly
            var a = new DifferentAssembly(....);
            var b = new DifferentAssembly(....);

            // pass by value. No error.
            Console.WriteLine(a + b);

            // pass by ref readonly.
            // No error in the Visual Studio C# Editor
            // but error on build.
            Console.WriteLine(a * b);

Expected Behavior:

successfully compiled

Actual Behavior:

There is no error in the Visual Studio C# Editor, but error on build.

image

@jcouv
Copy link
Member

jcouv commented Dec 10, 2017

Do you get a different behavior if the struct is declared in the same project/compilation?

@OmarTawfik recently fixed this scenario so that the by-val overload will be preferred in ambiguous situation. This fix is in master and should be available in 15.6 preview 2 (not yet released).
Test PassingInArgumentsOverloadedOnIn_BinaryOperators is close to what you describe, but within one compilation.

@jcouv jcouv added this to the 15.6 milestone Dec 10, 2017
@OmarTawfik
Copy link
Contributor

Yes. 15.5 didn't allow operators from other assemblies to be imported. #23508 fixed that (merged to master).
You can confirm quickly by either declaring your operators in the same assembly (should make the error go away), or trying the latest compiler from master, which should import the operator from the other assembly.

@VSadov
Copy link
Member

VSadov commented Jan 2, 2018

fixed in #23508

@VSadov VSadov closed this as completed Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants