error type Strange Error
Often this indicates that your code doesn't currently compile. Swift often has trouble computing types on code that itself isn't correct. In some cases it's a bug in the compiler. Use of AnyObject
can be particularly confusing to the compiler, and should be avoided as much as possible. In this case, AnyObject
is required, but you should try to get it converted to a specific type quickly. Don't return [AnyType]
for instance if you can possibly help it.
But the short answer is that the Swift compiler is still evolving, and it can't always work out types in complex situations, particularly on partial or (currently) incorrect code.
Note that you're using var
for a lot of things that should be let
. Unless you actually need to modify the variable, you should prefer let
. It helps you prevent many kinds of bugs, and can be easier on the compiler to deal with (since the variable has fewer ways it can change).
Strange error in C++ without stoping the program
The problem is that in your numOfDifferentElements
function, if the if
condition is satisified then there is no return statement. The problem is because the return type of the function is non-void and so you must return something. You can solve this by adding a return
statement inside the if
block or outside(after) the else
block as shown below:
int numOfDifferentElements(BSTree* root, int counter)
{
if (root)
{
counter++;
numOfDifferentElements(root->left, counter);
numOfDifferentElements(root->right, counter);
//can also add a return statement here
}
else
{
return counter;
}
//or add return -1; or some other value indicating ERROR CODE
}
F# strange type error message
Your error is caused by the fact, that each evaluation that execute in the FSI actually creates a dynamic assembly FSI_XXXX. So in fact, your function that you defined with ExprTree
was maybe referring to FSI_0051.ExprTree
whereas a function that you defined later and used ExprTree
is now referring to FSI_0061.ExprTree
.
What I typically do to fix the error, is just execute the definition of all my functions using ExprTree
again, now that there is a newer FSI_0061.ExprTree
and all should work.
You simply need to be aware, that each new evaluation with the same name will shadow the pre-existing symbol. On the other hand, they are still distinct symbols, hence the two names FSI_0051.ExprTree
and FSI_0061.ExprTree
.
Scala strange type error in Play Framework form
Saying def form[NewPostValidator]
is like saying def form[T]
, just with a different identifier. Compiler doesn't see the NewPostValidator in the method body as the "real" NewPostValidator, but as your made-up type NewPostValidator that you declared in def form[NewPostValidator]
.
Solution:
Parameterize your trait with [T] instead of your method, and have your class extend the trait with a specific type.
trait Delivery[T] {
def form(): Form[T]
}
object NewPost extends Delivery[NewPostValidator] {
def form(): Form[NewPostValidator] = Form(mapping(
"town" -> nonEmptyText,
"number" -> number)(NewPostValidator.apply)(NewPostValidator.unapply))
}
Strange error with Android Studio selection
Error was fixed by disabling Vim plugin
Strange error, Exception Value: type object has no attribute 'DoesNoExist'
The correct is hotel.DoesNotExist not hotel.DoesNoExiste a
Related Topics
Add Switch in Uitableview Cell in Swift
Swiftui Foreach Based on State Int
Swift: How to Call Cckeyderivationpbkdf from Swift
When to Use [Self] VS [Weak Self] in Swift Blocks
How to Check the Network Speed Using Swift
Store a Closure as a Variable in Swift
How to Create Nsradiobutton Group in Xcode 7 Osx
Getting Country Name from Country Code
What's the Equivalent to String.Localizedstringwithformat(_:_:) for Swiftui's Localizedstringkey
Uicollectionview Compositionallayout Not Calling Uiscrolldelegate
Anonymous Closure Argument Not Contained in a Closure
How to Have a Swift Script Use Multiple Files
Confusion Due to Swift Lacking Implicit Conversion of Cgfloat
How to Remove Spaces from a String in Swift
Check If Class Conforms to Protocol
Does Swift Guarantee the Storage Order of Fields in Classes and Structs
How to Rotate Only One View Controller to Landscape Orientation in iOS Swift 3