test: cover method return multiplication diagnostics
This commit is contained in:
@@ -198,7 +198,7 @@ Function square declares an unknown return type BANANA. Use a Claro type such as
|
||||
|
||||
The same check applies to methods, so `Player.score RETURNS BANANA` reports `Method Player.score declares an unknown return type BANANA...` instead of allowing a misspelled type into a class definition. If a return expression cannot be understood yet, the diagnostic names the function or method and the type it needs; this is covered for both modern and older compatibility method syntax. When a NUMBER return contains a known TEXT operand in arithmetic, the checker names the operation and operand, for example: `Type mismatch for return from total: addition needs NUMBER values, but "oops" looks like TEXT.` Complete `IF`/`ELSE` return branches are also accepted inside typed functions and methods, including a nested conditional whose own branches all return; an incomplete path still gets a missing-return diagnostic.
|
||||
|
||||
The same return diagnostic names the arithmetic operation when a NUMBER return mixes in a known TEXT operand, so the learner sees both the operation rule and the offending value instead of only a generic return mismatch. This is covered for addition, subtraction, multiplication, and division in functions, and for subtraction in object methods. For example, `Player.total` reports `subtraction needs NUMBER values` when its return expression mixes a checked NUMBER parameter with a TEXT value.
|
||||
The same return diagnostic names the arithmetic operation when a NUMBER return mixes in a known TEXT operand, so the learner sees both the operation rule and the offending value instead of only a generic return mismatch. This is covered for addition, subtraction, multiplication, and division in functions, and for subtraction, multiplication, and division in object methods. For example, `Player.total` reports `subtraction needs NUMBER values` when its return expression mixes a checked NUMBER parameter with a TEXT value.
|
||||
|
||||
Claro keywords are case-insensitive here, so `returns NUMBER` is accepted as the same return declaration as `RETURNS NUMBER`. The type checker keeps the return-value diagnostic when a lowercase declaration is used, which helps learners who are still learning Claro's capitalization style.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user