Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen committed Jan 18, 2025
1 parent 7620c00 commit b0b724d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/libponyc/expr/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,20 +497,16 @@ bool expr_case(pass_opt_t* opt, ast_t* ast)
if(!infer_pattern_type(pattern, match_type, opt))
return false;

ast_t* declared_pattern_type = make_pattern_type(opt, pattern);
if(declared_pattern_type == NULL)
return false;

ast_settype(ast, declared_pattern_type);

ast_t* pattern_type = consume_type(declared_pattern_type, TK_NONE, false);
ast_t* pattern_type = make_pattern_type(opt, pattern);
if(pattern_type == NULL)
return false;

ast_settype(ast, pattern_type);

bool ok = true;
errorframe_t info = NULL;

switch(is_matchtype(match_type, declared_pattern_type, &info, opt))
switch(is_matchtype(match_type, pattern_type, &info, opt))
{
case MATCHTYPE_ACCEPT:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libponyc/type/matchtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,

// TODO discuss with joe
if (consumed_pattern != pattern)
ast_free_unattached(consumed_pattern);
ast_free_unattached(consumed_pattern);

return rslt;
}
Expand Down
2 changes: 1 addition & 1 deletion test/libponyc/badpony.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ TEST_F(BadPonyTest, MatchIsoLetWithoutConsume)
" let a: String iso = recover iso String end\n"

" match a\n"
" | let a': String => None\n"
" | let a': String iso => None\n"
" end";

TEST_ERRORS_1(src, "this capture violates capabilities");
Expand Down

0 comments on commit b0b724d

Please sign in to comment.