Skip to content

Commit

Permalink
Merge pull request #128 from myuon/issue-122
Browse files Browse the repository at this point in the history
  • Loading branch information
myuon authored Sep 24, 2023
2 parents 2d759b9 + 24d49ba commit 9a74bd8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions quartz/typecheck.qz
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,12 @@ fun unify(type1: Type, type2: Type): Type or error {
if type2.t_nil != nil && type1.t_optional != nil {
return type1;
}
if type1.t_nil != nil && type2.t_ptr != nil {
return type2;
}
if type2.t_nil != nil && type1.t_ptr != nil {
return type1;
}
if type1.t_any != nil {
return type2;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/cases/test24.qz
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fun main(): bool {
let p = make[ptr[i32]](1);

return p == nil;
}
1 change: 1 addition & 0 deletions tests/cases/test24.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
false
10 changes: 9 additions & 1 deletion tests/compile_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ fn test_run() -> Result<()> {

if stdout_path.exists() {
let expected = fs::read_to_string(stdout_path)?;
let run = output.run.clone().unwrap();
let run = output.run.clone().expect(
format!(
"output.run is None.\n{}\n[COMPILE]: {}\n{}",
path.display(),
output.compile.stdout,
output.compile.stderr
)
.as_str(),
);

assert_eq!(
expected,
Expand Down

0 comments on commit 9a74bd8

Please sign in to comment.