x


Internal compiler error. (...) warning CS0162: Unreachable code detected

Most of times I get "Internal compiler error", I just edit anything in any file so it will recompile and then it goes away. Restarting Unity is another way of doing that same thing: triggering the compiler.

This time nothing of that worked.

What could have happened?

more ▼

asked Jul 04, 2013 at 08:03 PM

Cawas gravatar image

Cawas
2.3k 116 110 127

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

SisterKy have already compiled a fine list for the "what could have happened" part.

The warning, at other hand, gives a very specific information about what did happen: "Unreachable code". I think it is still a compiler bug because of this simple test which does reproduce the same error (which was coincidentally already mentioned by cowlinator elsewhere). Just create an empty project and add this file:

 using UnityEngine;
 using System.Collections;
 
 public class test : MonoBehaviour
 {
     const // simply remove this line, and error will disappear
         bool foo = false;
     
     void Start ()
     {
         StartCoroutine( bar() );
     }
     
     IEnumerator bar ()
     {
         yield return 0;
         
         if (foo)
         {
             yield return 0;
         }
         
         Debug.Log("finished!");
     }
 }
 

Once you know where this little bug is located it becomes pretty simple to find many ways to go around it. One way is using static readonly instead of const.

more ▼

answered Jul 04, 2013 at 08:03 PM

Cawas gravatar image

Cawas
2.3k 116 110 127

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x62

asked: Jul 04, 2013 at 08:03 PM

Seen: 936 times

Last Updated: Jul 04, 2013 at 08:08 PM