assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

fix: handle void to void during `convertExpression`

Open HerrCai0907 opened this issue 1 year ago • 4 comments

Fix: #2205

  • [x] I've read the contributing guidelines
  • [x] I've added my name and email to the NOTICE file

HerrCai0907 avatar Aug 06 '22 07:08 HerrCai0907

Iirc the idea of the assert is that if one converts nothing to nothing, then there isn't an expression to begin with that can be consumed as part of the conversion. Conceptionally, this would be a drop of a drop, but there's nothing to drop, so nothing to produce. As such I wonder if hitting the assertion in the first place is a sign that other code does something wrong prior?

dcodeIO avatar Aug 06 '22 15:08 dcodeIO

Yeah, btw (drop (drop (...))) is not valid operation. But it's not possible on practice due to drop has [any] -> [] signature. Or I missing something? Also on user space we can't produce explicit drops

MaxGraey avatar Aug 06 '22 15:08 MaxGraey

Perhaps we should add new UNKNOWN type kind as a top type which always should be resolved at the end (or at first access). In this case we could distinguish VOID from uninit expressions better for such cases

MaxGraey avatar Aug 06 '22 15:08 MaxGraey

As such I wonder if hitting the assertion in the first place is a sign that other code does something wrong prior?

@dcodeIO Because it used a un-initialized Global and throw Diagnosis before. So the this.currentType become VOID.

HerrCai0907 avatar Aug 06 '22 16:08 HerrCai0907

@dcodeIO What is your opinion about this PR?

HerrCai0907 avatar Aug 21 '22 02:08 HerrCai0907

Tried to come up with a comment so, in case we ever run into issues here, we know what was the intention :)

dcodeIO avatar Aug 21 '22 02:08 dcodeIO

Thanks!

MaxGraey avatar Aug 21 '22 02:08 MaxGraey