Skip to content

Commit 9fc0ac9

Browse files
committed
feat: syntax error vs panic + fix linting
1 parent bda0277 commit 9fc0ac9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/asm/assembler/linker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ func (p *Linker) linkExprs(es []macro.Expr) *source.SyntaxError {
262262

263263
func (p *Linker) getLabelValue(l string) (big.Int, string) {
264264
var deats util.Pair[big.Int, uint]
265+
//
265266
var ok bool
267+
//
266268
if l != "" {
267269
deats, ok = p.constmap[module.NewName(l, 1)]
268270
//
@@ -271,6 +273,7 @@ func (p *Linker) getLabelValue(l string) (big.Int, string) {
271273
return big.Int{}, msg
272274
}
273275
}
276+
//
274277
return deats.Left, ""
275278
}
276279

pkg/asm/assembler/parser.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ func (p *Parser) parseTernaryRhs(targets []io.RegisterId, env *Environment) (mac
596596
rhs = e.Constant
597597
label = e.Label
598598
case *expr.RegAccess:
599-
panic(fmt.Sprintf("ternary operator does not support register on the rhs"))
599+
// We can invoke (p.index - 1) as we are in the case of a ternary operator
600+
// Checks are already performed to have a lhs
601+
return nil, p.syntaxErrors(p.tokens[p.index-1], "ternary operator does not support register on the rhs")
600602
}
601603
// expect question mark
602604
if _, errs = p.expect(QMARK); len(errs) > 0 {

0 commit comments

Comments
 (0)