Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler crash on non-existent field reference in constructor. #1941

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libponyc/pass/refer.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,9 @@ static bool is_lvalue(pass_opt_t* opt, ast_t* ast, bool need_value)
if(ast_id(left) == TK_THIS)
{
ast_t* def = (ast_t*)ast_data(ast);
pony_assert(def != NULL);

if(def == NULL)
return false;

switch(ast_id(def))
{
Expand Down
13 changes: 13 additions & 0 deletions test/libponyc/badpony.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,19 @@ TEST_F(BadPonyTest, CallArgTypeErrorInsideTuple)
TEST_ERRORS_1(src, "argument not a subtype of parameter");
}

TEST_F(BadPonyTest, NonExistFieldReferenceInConstructor)
{
// From issue #1932
const char* src =
"actor Main\n"
" new create(env: Env) =>\n"
" this.x = None";

TEST_ERRORS_2(src,
"can't find declaration of 'x'",
"left side must be something that can be assigned to");
}

TEST_F(BadPonyTest, TypeArgErrorInsideReturn)
{
const char* src =
Expand Down