Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the compiler signal error on (-) or (/ 1 0)? (At compilation time?) #647

Open
jpellegrini opened this issue May 29, 2024 · 0 comments

Comments

@jpellegrini
Copy link
Contributor

Not sure about this @egallesio . Tell me what you think..,.

If we turn off inlining,

stklos> (define (f) (/ 1 0))
;; f
stklos> (define (g) (-))
;; g

stklos> (disassemble f)

000:  PREPARE-CALL        
001:  ONE-PUSH            
002:  ZERO-PUSH           
003:  GREF-TAIL-INVOKE     0 2
006:  RETURN              
007:

stklos> (disassemble g #t)

000:  PREPARE-CALL        
001:  GREF-TAIL-INVOKE     0 0
004:  RETURN              
005:

But with the default (inlining turned on):

stklos> (define (f) (/ 1 0))
**** Error:
/: cannot make rational with null denominator
(type ",help" for more information)
stklos> (define (g) (-))
**** Error:
compiler-error: -: needs at least one argument
(type ",help" for more information)

And disassemble-expression signals an error:

stklos>  (disassemble-expr '(-) #t)
**** Error:
compiler-error: -: needs at least one argument

The previous one was a compilre error. The following is a generic error (because it was not caught in the ilining code - easy o fix actually):

stklos>  (disassemble-expr '(/ 1 0) #t)
**** Error:
/: cannot make rational with null denominator
	(type ",help" for more information)

So... Should the compiler crash when an inlinable expression is not calculable, or should we just, well, leave it there un-optimized, so it will crash when the code is executer? (I'd argue for signaling the error during compilation -- which is, leave it as it is -- as this is useful).

@jpellegrini jpellegrini changed the title Should the compiler crash on (-) or (/ 1 0)? Should the compiler signal error on (-) or (/ 1 0)? (At compilation time?) May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant