-
Notifications
You must be signed in to change notification settings - Fork 79
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
Type Error in type_check_Ctup.py #32
Comments
@jsiek this issue is for the Python support code, even though it's been posted on the Racket support code repo. Here is the complete error trace for @Trac91iu's compiler when run on the
|
@Trac91iu's solution to modify def type_check_exp(self, e, env):
match e:
case GlobalValue(name):
return self.type_check_atm(e, env)
... This would make the example code in the textbook and the lecture slides type-check successfully as well. I believe this bug was introduced in this commit: IUCompilerCourse/python-student-support-code@04dbae2. Therefore, it seems like we need to handle the Let me know if I should push this fix to the Python support code repository @jsiek. |
Yes, did the same as you suggest. (Didn't see your comment until after I already pushed.) |
I’ve been testing the tuple but keep encountering the following error:
Traceback (most recent call last):
File "/home/autograder/working_dir/run-tuple-test.py", line 22, in
run_one_test(os.getcwd() + '/tests/' + lang + '/' + test + '.py', lang,
File "/home/autograder/working_dir/utils.py", line 1606, in run_one_test
return compile_and_test(compiler, compiler_name, type_check_dict,
File "/home/autograder/working_dir/utils.py", line 1418, in compile_and_test
type_check_dictpassname
File "/home/autograder/working_dir/type_check_Cif.py", line 115, in type_check
self.type_check_stmts(ss[:-1], env)
File "/home/autograder/working_dir/type_check_Cif.py", line 78, in type_check_stmts
self.type_check_stmt(s, env)
File "/home/autograder/working_dir/type_check_Ctup.py", line 76, in type_check_stmt
return super().type_check_stmt(s, env)
File "/home/autograder/working_dir/type_check_Cif.py", line 83, in type_check_stmt
t = self.type_check_exp(value, env)
File "/home/autograder/working_dir/type_check_Ctup.py", line 58, in type_check_exp
return super().type_check_exp(e, env)
File "/home/autograder/working_dir/type_check_Cif.py", line 74, in type_check_exp
raise Exception('error in type_check_exp, unexpected ' + repr(e))
Exception: error in type_check_exp, unexpected GlobalValue(name='free_ptr')
After investigating, I looked into type_check_Ctup.py and noticed that the type_check_exp function doesn't seem to handle the GlobalValue case. When I assign a GlobalValue to a variable, Assign takes exp as an input, and GlobalValue appears to be a type of exp as well.
If the remove complex operand give statement "tmp.4 = (free_ptr + 32)", it works fine. But according to the slides and the python-book, they both suggest using "tmp.3 = free_ptr". Given the grammar (Figure 7.12), "tmp.3 = free_ptr" should also pass the type checker. Therefore, would it be better to add a case in the type_check_exp function in type_check_Ctup.py to handle the GlobalValue? For example: case GlobalValue(name): return self.type_check_atm(e, env)).
The text was updated successfully, but these errors were encountered: