Closed ghallak closed 2 years ago
@hanssv @radrow I'm looking for a way to properly report the warnings. Right now, the warnings are all stored in an ets_table called warnings
in the aeso_ast_infer_types.erl
file.
Do you think I should keep forwarding the warnings as strings upwards until they get to the aeso_compiler:from_string
function and then I can return them along with the compilation result? or is there another way to do that?
I think that warnings should be returned as renderable structures as a result of the compilation/infer function
Yes, keeping them in some warning structure (similar to the errors) and passing them upwards sounds like the best alternative. Then we can present them, or return them (or ignore them) according to options I guess.
For negative spends and division by zero, the warning will only show when using a literal.
function f() =
let x = 1 / 0 // this is a warning
let zero = 0
let y = 1 / zero // no warning will show here
let z = 1 / (1 - 1) // no warning will show here
I think it won't be very difficult to add warning for the second case 1 / zero
since this will only need to lookup the value of the variables zero
, but the third case will requires evaluating the expression 1 - 1
, which will make things more complicated and I'm not sure if I should try to add that.
but the third case will requires evaluating the expression
1 - 1
, which will make things more complicated and I'm not sure if I should try to add that.
I guess if the compiler have a optimization phase to evaluate that and you run the warning check in a step/phase after it it would be covered by case 1
there could be a second pass of warning check after additional constant propagation
Would be nice to reflect it in the cli and http interface too
@nikita-fuchs would be great to see it working in aestudio :)
@nikita-fuchs would be great to see it working in aestudio :)
dayumn, thanks for bringing this up.
Currently added warnings:
stateful
annotationsCurrently supported options:
Things that still need to be done:
Testing: