fix ambiguous type error to actually work
authorBrian Frank
Tue Jul 14 14:06:45 2009 -0400 (13 months ago)
changeset 1698b040618d9935
parent 1697 b57cf92d01e7
child 1699 7c0c44073b0a
fix ambiguous type error to actually work
src/compiler/fan/parser/Parser.fan
src/testCompiler/fan/NamespaceTest.fan
     1.1 --- a/src/compiler/fan/parser/Parser.fan	Tue Jul 14 13:43:21 2009 -0400
     1.2 +++ b/src/compiler/fan/parser/Parser.fan	Tue Jul 14 14:06:45 2009 -0400
     1.3 @@ -2198,8 +2198,9 @@
     1.4        return ns.voidType
     1.5      }
     1.6  
     1.7 -    // if more then one it is ambiguous
     1.8 -    if (types.size > 1) err("Ambiguous type: " + types.join(", "))
     1.9 +    // if more then one its ambiguous (use errReport to avoid suppression)
    1.10 +    if (types.size > 1)
    1.11 +      errReport(CompilerErr("Ambiguous type: " + types.join(", "), loc))
    1.12  
    1.13      // got it
    1.14      return types.first
     2.1 --- a/src/testCompiler/fan/NamespaceTest.fan	Tue Jul 14 13:43:21 2009 -0400
     2.2 +++ b/src/testCompiler/fan/NamespaceTest.fan	Tue Jul 14 14:06:45 2009 -0400
     2.3 @@ -438,4 +438,36 @@
     2.4         ])
     2.5    }
     2.6  
     2.7 +//////////////////////////////////////////////////////////////////////////
     2.8 +// Ambiguous
     2.9 +//////////////////////////////////////////////////////////////////////////
    2.10 +
    2.11 +  Void testAmbiguous()
    2.12 +  {
    2.13 +    x := podName
    2.14 +    compile("class Foo {}\nclass Bar {}")
    2.15 +    xp := pod
    2.16 +
    2.17 +    y := podName
    2.18 +    compile("class Foo {}\nclass Bar {}\nclass Baz {}")
    2.19 +    yp := pod
    2.20 +
    2.21 +    verifyErrors(
    2.22 +    "using $x
    2.23 +     using $y
    2.24 +     class Test
    2.25 +     {
    2.26 +       Obj? m05() { return Foo# }
    2.27 +       Obj? m06() { return Bar#.bar }
    2.28 +       Obj? m07() { return (Baz)m06 }
    2.29 +     }
    2.30 +     class Foo {}
    2.31 +     class Baz {}",
    2.32 +     [
    2.33 +       5, 23, "Ambiguous type: $podName::Foo, $x::Foo, $y::Foo",
    2.34 +       6, 23, "Ambiguous type: $x::Bar, $y::Bar",
    2.35 +       7, 24, "Ambiguous type: $podName::Baz, $y::Baz",
    2.36 +     ])
    2.37 +  }
    2.38 +
    2.39  }
    2.40 \ No newline at end of file