Skip to content

Commit 29770ae

Browse files
authored
Merge pull request #525 from Daniel-Cortez/fix-524
Fix assertion failure when a native operator is declared without a base function
2 parents 461ca7b + 309fca1 commit 29770ae

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

source/compiler/sc1.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,11 +3682,7 @@ static void funcstub(int fnative)
36823682
* for a native function, this is optional
36833683
*/
36843684
if (fnative) {
3685-
if (opertok!=0) {
3686-
needtoken('=');
3687-
lexpush(); /* push back, for matchtoken() to retrieve again */
3688-
} /* if */
3689-
if (matchtoken('=')) {
3685+
if ((opertok!=0) ? needtoken('=') : matchtoken('=')) {
36903686
/* allow number or symbol */
36913687
if (matchtoken(tSYMBOL)) {
36923688
tokeninfo(&val,&str);

source/compiler/tests/gh_525.meta

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
'test_type': 'output_check',
3+
'errors': """
4+
gh_525.pwn(1) : error 001: expected token: "=", but found ";"
5+
"""
6+
}

source/compiler/tests/gh_525.pwn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
native Tag:operator+(Tag:a, Tag:b); // error 001: expected token: "=", but found ";"
2+
3+
// Make sure that valid native operator and function declarations aren't affected
4+
native Tag2:operator+(Tag2:a, Tag2:b) = NativeFunc;
5+
native Tag2:NativeFunc(Tag2:a, Tag2:b);
6+
native NativeFunc2(a,b) = NativeFunc;
7+
8+
main(){}

0 commit comments

Comments
 (0)