Skip to content

Commit cd4dcf3

Browse files
committed
fixes bug with repeat
1 parent bc4c491 commit cd4dcf3

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

FadeBasic/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.48] - 2026-02-24
9+
10+
### Fixed
11+
- able to use variable in `REPEAT` conditionals that was defined within the `REPEAT` block
12+
813
## [0.0.47] - 2026-02-22
914

1015
### Added

FadeBasic/FadeBasic/Ast/Visitors/ScopeErrorVisitor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,17 @@ static void CheckStatements(this List<IStatementNode> statements, Scope scope, E
418418
scope.EndLoop();
419419
break;
420420
case RepeatUntilStatement repeatStatement:
421+
422+
scope.BeginLoop();
423+
repeatStatement.statements.CheckStatements(scope, ctx);
424+
scope.EndLoop();
421425
repeatStatement.condition.EnsureVariablesAreDefined(scope, ctx);
422426
scope.EnforceTypeAssignment(repeatStatement.condition, repeatStatement.condition.ParsedType, TypeInfo.Int, false, out _);
423427

424428
scope.BeginLoop();
425429
repeatStatement.statements.CheckStatements(scope, ctx, inheritTransitiveTypeFlagsFrom: new IAstNode[]{repeatStatement.condition});
426430
scope.EndLoop();
427-
431+
428432
break;
429433
case GoSubStatement goSub:
430434
EnsureLabel(scope, goSub.label, goSub);

FadeBasic/Tests/ParserTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,35 @@ FUNCTION soap()
143143
}
144144

145145

146+
147+
[Test]
148+
public void Bug_0_0_47_1_RepeatDecl()
149+
{
150+
var input = @"
151+
repeat
152+
x = 3
153+
until x = 0
154+
";
155+
var parser = MakeParser(input);
156+
var prog = parser.ParseProgram();
157+
prog.AssertNoParseErrors();
158+
}
159+
160+
161+
[Test]
162+
public void Bug_0_0_47_1_RepeatDecl_Clarification_onlyOnce()
163+
{
164+
var input = @"
165+
repeat
166+
x = `only 1 error should appear
167+
until 1
168+
";
169+
var parser = MakeParser(input);
170+
var prog = parser.ParseProgram();
171+
prog.AssertParseErrors(1);
172+
}
173+
174+
146175
[Test]
147176
public void Function_Docs_Trivia_MultiLine_Blank()
148177
{

0 commit comments

Comments
 (0)