Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A couple of potential bugs
#4
Thanks for the feedback Smile

Regarding 'right', I designed it to function like that already in the first version of naalaa. 'right' returns the opposite part of a string compared to 'left', because whenever I (myself) use 'right' it's in some sort of combination with 'left'.

The problem with the other errors is that n7 doesn't do ANY type checking at compile time (much like Lua), because variables are allowed to change type at runtime. And, yes, that is kind of bad in the cases where the errors are "obvious". I should try to detect these cases and atleast output warnings.

Code:
visible foo = [1, 2, 3, 4, 5]

bar()
pln foo(4)

function bar()
    if rnd(2) = 0
        foo = function(x)
            return x^2
        endfunc
    else
        foo = baz
    endif
endfunc

function baz(x)
    return |x|
endfunc

If you look at the above code, you might see the beginning of how complicated these checks could become. And that's pretty much why I never bothered to make any checks at all.

In your examples, the compiler just assumes that the variables hold functions and that you're trying to call them. "(renv) bugs.n7:24: runtime error: Register is not a label (BC_CALL_R)" Haha, and that is what you get when you try to make a function call through a variable that isn't a function. I should definitely change that runtime error message, sorry Smile
Reply


Messages In This Thread
A couple of potential bugs - by eddavis - 11-01-2022, 05:11 PM
RE: A couple of potential bugs - by johnno1956 - 11-01-2022, 06:49 PM
RE: A couple of potential bugs - by eddavis - 11-01-2022, 07:02 PM
RE: A couple of potential bugs - by Marcus - 11-03-2022, 05:48 AM
RE: A couple of potential bugs - by Marcus - 11-05-2022, 04:30 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)