cimplec / sim-c

A dynamically typed high-level front end for C

Home Page:https://cimplec.github.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG REPORT] Function cannot be called multiple times

frankhart2018 opened this issue · comments

Describe the bug
A function defined in simC can be called once currently, when calling it again it throws error.

Hi there! @frankhart2018
For some reason calling the function twice is already working for me.
Simc Code:
fun sum ( a, b ) {
return a + b
}

MAIN
var A = input( "Enter an integer: ", "i" )
var B = input( "Enter another integer: ", "i" )

//C = sum ( A, B )
var C = sum( A,B )
print( "SUM: " )
print( C )
print( "\n" )

var D = sum( C,B )

print( "SUM2: " )
print( D )
print( "\n" )

END_MAIN

Corresponding C Code:
#include <stdio.h>

int sum(int a, int b) {

return a + b;

}

int main() {
int A;
printf("Enter an integer: ");
scanf("%d", &A);
int B;
printf("Enter another integer: ");
scanf("%d", &B);
// C = sum ( A, B )
int C = sum(A, B);
printf("SUM: ");
printf("%d", C);
printf("%c", '\n');
int D = sum(C, B);
printf("SUM2: ");
printf("%d", D);
printf("%c", '\n');

return 0;

}

Output of C Code:
image

Yeah now it is working for me too, weird 😄. Closing this then. Thanks for reporting @Chasmiccoder.