Ambiguity can refer to two related concepts: 'ambiguous calls' and 'ambiguous grammars'.
Questions tagged [ambiguity]
372 questions
72
votes
6 answers
The variable 'MyException' is declared but never used
I need to clear this warning :
try
{
doSomething()
}
catch (AmbiguousMatchException MyException)
{
doSomethingElse()
}
The complier is telling me :
The variable 'MyException' is declared but never used
How can I fix this.
Wassim AZIRAR
- 10,179
- 36
- 115
- 165
69
votes
3 answers
How to set break point on one file of a project which has many files with same name?
I want to set a break point in gdb on file service.cpp on line 45 and I do:
gdb> break service.cpp:45
The problem is that there are many service.cpp files in my application and it is not picking the one I am interested in. How can I specify the…
WilliamKF
- 36,283
- 61
- 170
- 271
56
votes
5 answers
Django model with 2 foreign keys from the same table
I wanted a Django model with 2 foreign keys from the same table. It's an event table which has 2 columns for employees: the 'actor' and the 'receiver'. But I get this error:
Error: One or more models did not validate: tasks.task: Intermediary
…
Josh
- 1,235
- 2
- 13
- 21
49
votes
4 answers
warning: refname 'xxx' is ambiguous when using git-svn
I am using git as a frontend to Subversion (via git svn).
So, for every svn trunk/branch I have remote branch in git named "remotes/xxx". For example "remotes/trunk", "remotes/coolfeature".
Now I want have one "default" local branch for every remote…
Ivan Dubrov
- 4,670
- 2
- 27
- 38
43
votes
4 answers
No warning or error (or runtime failure) when contravariance leads to ambiguity
First, remember that a .NET String is both IConvertible and ICloneable.
Now, consider the following quite simple code:
//contravariance "in"
interface ICanEat where T : class
{
void Eat(T food);
}
class HungryWolf : ICanEat,…
Jeppe Stig Nielsen
- 54,796
- 9
- 96
- 154
42
votes
3 answers
C# The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int)
My code won't compile due to the error below:
The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int)
My code is
Math.Round(new FileInfo(strFilePath).Length / 1024,…
James B
33
votes
9 answers
C# interface method ambiguity
Consider the following example:
interface IBase1
{
int Percentage { get; set; }
}
interface IBase2
{
int Percentage { get; set; }
}
interface IAllYourBase : IBase1, IBase2
{
}
class AllYourBase : IAllYourBase
{
int percentage;
int…
void.pointer
- 21,280
- 21
- 106
- 196
31
votes
3 answers
Why is it ambiguous to call overloaded ambig(long) and ambig(unsigned long) with an integer literal?
When compiling
void ambig( signed long) { }
void ambig(unsigned long) { }
int main(void) { ambig(-1); return 0; }
I get
error C2668: 'ambig' : ambiguous call to overloaded function
could be 'void ambig(unsigned long)'
or 'void…
user541686
- 189,354
- 112
- 476
- 821
22
votes
3 answers
What happens when a class and a function have the same name?
#include
using namespace std;
struct test
{
test(){cout<<"class"<
user3514538
- 2,294
- 1
- 11
- 21
21
votes
2 answers
Ambiguous implicit values
I've been thinking I understand scala implicits until recently faced strange problem.
In my application I have several domain classes
case class Foo(baz: String)
case class Bar(baz: String)
And a class that is able to construct domain object from…
lambdas
- 3,818
- 2
- 25
- 52
19
votes
2 answers
Compile time warning when using 'Microsoft.Office.Interop.Word._Document.Close'
Anyone know how to solve this warning message?
Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'. Using method…
Mah Jin Khai
- 1,004
- 1
- 11
- 29
19
votes
3 answers
Why does C# allow ambiguous function calls through optional arguments?
I came across this today, and I am surprised that I haven't noticed it before. Given a simple C# program similar to the following:
public class Program
{
public static void Main(string[] args)
{
Method(); // Called the method with no…
Adam Goodwin
- 3,390
- 4
- 25
- 29
18
votes
5 answers
Anonymous Namespace Ambiguity
Consider the following snippet:
void Foo() // 1
{
}
namespace
{
void Foo() // 2
{
}
}
int main()
{
Foo(); // Ambiguous.
::Foo(); // Calls the Foo in the global namespace (Foo #1).
// I'm trying to call the `Foo` that's defined in the…
sharp02
- 183
- 1
- 4
18
votes
3 answers
Ambiguity with Action and Func parameter
How is it possible that this code
TaskManager.RunSynchronously(fileMananager.BackupItems, package);
causes a compile error
The call is ambiguous between the following methods or…
Ondrej Janacek
- 11,896
- 14
- 52
- 87
17
votes
2 answers
C++ method call and type scope resolution ambiguity
I hope the title actually describes what I wanted to ask...
I wrote a piece of code that compiles with gcc and works as I intended. However, it does not compile with llvm and the code executes differently when compiled with icc!
Here is an example…
Nowakus
- 533
- 4
- 6