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

Method generic type parameters are out of parameter list scope for 'nameof' expression #42

Closed
controlflow opened this issue Jan 19, 2015 · 4 comments · Fixed by #552
Closed
Labels
Area-Compilers Bug Language-C# Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Milestone

Comments

@controlflow
Copy link

[A(nameof(U))] // ok
class Test<U> {
  void M<T>(
    T t = default(T), // ok
    string s = nameof(T) // error CS0103: The name 'T' does not exist in the current context
  ) { }
}

class A : System.Attribute {
    public A(string s) { }
}

It compiles as expected in CTP4, but fails in current 'master'. Maybe related to #40.

@theoy theoy added this to the 1.0 milestone Jan 20, 2015
@paulomorgado
Copy link

According to "nameof operator - v5", it should work.

And it works for U.

@controlflow
Copy link
Author

Ugh, according to examples from v5 spec, maybe this is not a bug...

[Foo(nameof(T))] void f<T> { }
// result error "T not defined": A method type parameter is not in scope in an attribute on that method
void f([Attr(nameof(x))] int x) {}
// result error "x is not defined": A parameter is not in scope in an attribute on that parameter, or any parameter in the method

@controlflow
Copy link
Author

Accidentally closed the issue :/

@controlflow controlflow reopened this Jan 20, 2015
@gafter gafter added the Bug label Jan 20, 2015
@gafter gafter modified the milestones: 1.0-rc2, 1.0 (stable) Feb 14, 2015
gafter added a commit to gafter/roslyn that referenced this issue Feb 16, 2015
@gafter gafter added 4 - In Review A fix for the issue is submitted for review. and removed 3 - Working labels Feb 16, 2015
@gafter gafter removed the 4 - In Review A fix for the issue is submitted for review. label Feb 17, 2015
@gafter gafter assigned agocke and unassigned gafter Feb 18, 2015
@gafter
Copy link
Member

gafter commented Feb 18, 2015

Assigning to @agocke for verification.

@gafter gafter added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Mar 4, 2015
@agocke agocke removed their assignment Jun 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Language-C# Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants