Skip to content

Commit 1402556

Browse files
committed
Improve indexers
1 parent 2d7b658 commit 1402556

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/nes.fab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn ppu_upload_oam(U oam_offset)
212212
// Hides every sprite, starting from 'index':
213213
fn hide_oam(I.oam index)
214214
: +inline
215-
do for ; index; index += 4
215+
do for ; index != 0; index += 4
216216
: -unroll
217217
set_oam_y(index, $FF)
218218

src/eval.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4045,6 +4045,13 @@ expr_value_t eval_t::do_expr(ast_node_t const& ast)
40454045
{
40464046
indexer_type = array_val.type;
40474047

4048+
if(is8 && indexer_type.name() == TYPE_II)
4049+
{
4050+
throw compiler_error_t(
4051+
fmt_error(array_val.pstring, fmt("[] cannot be used on type %.", indexer_type))
4052+
+ fmt_note("Use {} instead."));
4053+
}
4054+
40484055
array_index = do_add<plus_p>(array_index, throwing_cast<D>(std::move(array_val), array_index.type, false), ast.token);
40494056
if(array_val.type.global().gclass() == GLOBAL_VAR || array_val.type.global().gclass() == GLOBAL_CONST)
40504057
array_val = global_ident<D>(array_val.type.global(), ast.token.pstring);
@@ -5721,7 +5728,7 @@ expr_value_t eval_t::do_assign(expr_value_t lhs, expr_value_t rhs, token_t const
57215728
precheck_tracked->gvars_used.emplace(gvar, lhs.pstring);
57225729
}
57235730
else if(!lhs.is_deref() && !is_check(D))
5724-
compiler_error(pstring, fmt("Unable to modify %", global.name));
5731+
compiler_error(pstring, fmt("Unable to modify %.", global.name));
57255732
}
57265733

57275734
type_t rhs_type = lhs.type;

src/type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ cast_result_t can_cast(type_t const& from, type_t const& to, bool implicit)
430430
return CAST_NOP;
431431

432432
// Can't implicitly cast away indexes.
433-
if(implicit && is_index(from.name()) && (!is_index(to.name()) || &from.global() != &to.global()) && to != TYPE_BOOL)
433+
if(implicit && is_index(from.name()) && (!is_index(to.name()) || &from.global() != &to.global()))
434434
return CAST_FAIL;
435435

436436
// PAAs should be converted to ptrs, prior.

0 commit comments

Comments
 (0)