Skip to content

Commit

Permalink
Fix compiler crash on "_" as argument in a case expression. (#1924)
Browse files Browse the repository at this point in the history
Resolves #1922.
  • Loading branch information
jemc authored May 20, 2017
1 parent 6e962ba commit 7590a42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libponyc/type/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ static bool is_x_sub_x(ast_t* sub, ast_t* super, check_cap_t check_cap,
pony_assert(sub != NULL);
pony_assert(super != NULL);

if(ast_id(super) == TK_DONTCARETYPE)
if((ast_id(super) == TK_DONTCARETYPE) || (ast_id(sub) == TK_DONTCARETYPE))
return true;

switch(ast_id(sub))
Expand Down
18 changes: 18 additions & 0 deletions test/libponyc/dontcare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,21 @@ TEST_F(DontcareTest, CannotUseDontcareInTupleRHS)

TEST_ERRORS_1(src, "can't read from '_'");
}


TEST_F(DontcareTest, CannotUseDontcareAsArgumentInCaseExpression)
{
// From issue #1922
const char* src =
"class C\n"
" new create(i: U32) => None\n"
" fun eq(that: C): Bool => false\n"

"primitive Foo\n"
" fun apply(c: (C | None)) =>\n"
" match c\n"
" | C(_) => None\n"
" end";

TEST_ERRORS_1(src, "can't read from '_'");
}

0 comments on commit 7590a42

Please sign in to comment.