Skip to content

Commit

Permalink
Fix a problem with $o being allowed in Exits leading to crash
Browse files Browse the repository at this point in the history
Fixes #175141885 and is the second half of, and thus also fixes #18
  • Loading branch information
thoni56 committed Oct 12, 2020
1 parent d560598 commit 7fb9b1b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/stm.c
Expand Up @@ -251,7 +251,8 @@ static void analyzePrint(Statement *stm, Context *context)
i++;
if (isdigit((int)buffer[i]))
parameter = buffer[i] - '0';
}
} else if (buffer[i] == 'o')
parameter = 1;
} else
parameter = buffer[i] - '0';
if (parameter != 0)
Expand Down
2 changes: 1 addition & 1 deletion compiler/testing/analyzePrintStatement.alan
@@ -1,7 +1,7 @@
The l Isa location
Exit w To l Does
"We can'print a parameter like $1."
"But should also not allow $0."
"But should also not allow $o."
End Exit.
End The l.

Expand Down
22 changes: 22 additions & 0 deletions compiler/testing/analyzePrintStatement.expected
@@ -0,0 +1,22 @@
########## analyzePrintStatement ##########


analyzePrintStatement.alan

3. "We can'print a parameter like $1."
=====> 1

*1* 551 E : String contains reference to a parameter that does not exist in
this context.

4. "But should also not allow $o."
=====> 1

*1* 551 E : String contains reference to a parameter that does not exist in
this context.


2 error(s).
No detected warnings.
1 informational message(s).

Binary file modified regression/platforms/Darwin.a3c
Binary file not shown.

0 comments on commit 7fb9b1b

Please sign in to comment.