Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug ? Turning warning into errors...

Discussion in 'Scripting' started by Deleted User, Feb 10, 2016.

  1. Deleted User

    Deleted User

    Guest

    Hi all !

    I think I ran into some VS/Mono related bug. Here is a piece of code with 2 snippets that are doing the same thing. In case 1 the condition of the where is checking two booleans against each other, in case 2 it is just a single boolean.
    What happen is that if I use code 1, then unity start treating all my warning as errors and I cannot run game anymore. If I use 2 everything is fine.
    I would thank any explanation for this behavior that I do not understand ^^'...

    (note: the boolean isCorrect is not always true, it is just for illustration purpose)


    Code (CSharp):
    1.                             bool isCorrect = true;
    2.                             //1 - This is creating a problem
    3. iconMatch.sprite = (from m in MappingManager.Instance.m_boolean where (m.isRight == isCorrect) select m.sprite).First();
    4.                             //2 - This is working fine
    5. if (isCorrect)
    6.                                 iconMatch.sprite = (from m in MappingManager.Instance.m_boolean where m.isRight select m.sprite).First();
    7.                             else
    8.                                 iconMatch.sprite = (from m in MappingManager.Instance.m_boolean where !m.isRight select m.sprite).First();
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    Do you by any chance have an "Internal Compiler Error" logged anywhere?
     
  3. Deleted User

    Deleted User

    Guest

    No, the thing is that Visual Studio compile the project just fine. But when it comes to running it within unity I get warning reported as errors. And only one (if I fix it then the next one appears as an error and so on.)

    I just noticed an additional fact:
    the problem only appears if the instruction is contained within a lambda expression...
     
  4. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    In my experience, when Unity starts reporting warnings as errors, it means:
    1. You've specifically asked warnings to be treated as errors (which you don't appear to have)
    2. Unity's compiler has encountered an internal error, and all warnings discovered to that point appear as errors

    It sounds like you've run into the second case -- sometimes the compiler will attach the "internal compiler error" to the actual warning stack trace. Can you post the stack trace from one of your warnings that is being seen as an error?
     
  5. Deleted User

    Deleted User

    Guest

    Oh... Ok, I did not know that. Here it is...
    From googling it seems quite likely that there is some problem with this syntax and mono