Skip to content

Commit 9624172

Browse files
committed
Fixed multiple uses of LET in BASIC
1 parent 588815b commit 9624172

File tree

5 files changed

+64
-11
lines changed

5 files changed

+64
-11
lines changed

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 6.1.8
2+
- Fixed multiple uses of LET in BASIC programs
3+
14
Version 6.1.7
25
- Added `DEBUG_DISABLE` constant to disable DEBUG() in Spin2 objects
36
- Added %b flag for binary output in printf

Test/Expect/stest300.pasm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
pub main
2+
coginit(0, @entry, 0)
3+
dat
4+
org 0
5+
entry
6+
7+
_program
8+
mov arg01, #1
9+
wrlong arg01, objptr
10+
mov arg01, #2
11+
wrlong arg01, objptr
12+
or dira, #4
13+
or outa, #4
14+
mov arg01, #3
15+
wrlong arg01, objptr
16+
or dira, #8
17+
or outa, #8
18+
_program_ret
19+
ret
20+
21+
objptr
22+
long @@@objmem
23+
COG_BSS_START
24+
fit 496
25+
objmem
26+
long 0[1]
27+
org COG_BSS_START
28+
arg01
29+
res 1
30+
fit 496

Test/stest300.bas

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
' test for multiple lets not throwing issues
2+
' with redeclaration
3+
let r = 1
4+
let r = r+1
5+
6+
_drvh(r)
7+
8+
let r = r+1
9+
_drvh(r)

frontends/common.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,18 +2088,29 @@ DeclareOneMemberVar(Module *P, AST *ident, AST *type, int is_private)
20882088
// check to see if an identifier is already declared
20892089
// if it is, return the typ of it
20902090
// slightly different from FindDeclaration, which returns
2091-
// the declaration itself
2091+
// the declaration itself; also expects a different
2092+
// list structure, so we cannot re-implement AlreadyDeclared
2093+
// in terms of FindDeclaration :(
20922094
//
20932095
static AST *
20942096
AlreadyDeclared(AST *pendinglist, AST *newIdentifier)
20952097
{
2096-
const char *name = GetIdentifierName(newIdentifier);
2097-
AST *decl = FindDeclaration(pendinglist, name);
2098-
if (!decl) return decl;
2099-
if (decl && decl->kind == AST_DECLARE_VAR) {
2100-
AST *typ = decl->left;
2101-
if (!typ) typ = ast_type_generic;
2102-
return typ;
2098+
AST *entry;
2099+
AST *ident;
2100+
AST *typ;
2101+
while (pendinglist) {
2102+
entry = pendinglist->left;
2103+
pendinglist = pendinglist->right;
2104+
if (entry && entry->kind == AST_DECLARE_VAR) {
2105+
ident = entry->right;
2106+
if (AstUses(ident, newIdentifier)) {
2107+
typ = entry->right;
2108+
if (typ == NULL) {
2109+
typ = ast_type_generic;
2110+
}
2111+
return typ;
2112+
}
2113+
}
21032114
}
21042115
return NULL;
21052116
}

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#define str_(x) str__(x)
66

77
#define VERSION_MAJOR 6
8-
#define VERSION_MINOR 2
9-
#define VERSION_REV 0
10-
#define BETA "-beta"
8+
#define VERSION_MINOR 1
9+
#define VERSION_REV 8
10+
//#define BETA "-beta"
1111

1212
#define VERSIONSTR version_string
1313

0 commit comments

Comments
 (0)