How to check if the correct type is returned #28
Answered
by
ChocolateLoverRaj
ChocolateLoverRaj
asked this question in
Planning
-
define i1 @main () {
EntryBlock:
; Should not be allowed to return i32
ret i32 0
} |
Beta Was this translation helpful? Give feedback.
Answered by
ChocolateLoverRaj
Jan 21, 2023
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Why this makes senseIt is the return instruction's "fault" that the wrong type is returned. Usually u change the returned type to the correct one, not the function's defined return type How it would work
[
file,
function,
block,
]
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ChocolateLoverRaj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReturnInstruction
node checks if the returned type matches the return type of the function that it's inFunction
node that the return instruction is inside.Why this makes sense
It is the return instruction's "fault" that the wrong type is returned. Usually u change the returned type to the correct one, not the function's defined return type
How it would work
check()
function would receive an array of parent nodes. In the sample this would be: