Skip to content

Commit

Permalink
Fix wrong globals being added
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Apr 15, 2024
1 parent 81a6851 commit 655e65b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/compiler.pr
Original file line number Diff line number Diff line change
Expand Up @@ -3210,7 +3210,10 @@ def walk_Identifier(node: &parser::Node, state: &State) -> Value {
if (@val).global {
let name = val.assembly_name(state)
(@(@state).module).imported.add(name)
if val.module != state.module {
if val.module != state.module and
not is_function(val.tpe) and
not state.module.result.globals.contains(name) {

state.module.result.globals(name) = [
tpe = val.tpe,
name = name,
Expand Down
6 changes: 3 additions & 3 deletions src/consteval.pr
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ export def walk_Def(node: &parser::Node, state: &typechecking::State) {
let impl = node.value.def_.impl
let has_yield = node.value.def_.has_yield

let prev_context = state.context
state.context = state.module.scope
defer state.context = prev_context
//let prev_context = state.context
//state.context = state.module.scope
//defer state.context = prev_context

var body = node.value.def_.body
let imported = (share !int & parser::ShareMarker::IMPORT !int) != 0
Expand Down
2 changes: 1 addition & 1 deletion src/parser.pr
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export let invalid_loc: SourceLoc = [
] !SourceLoc

export def is_invalid(loc: SourceLoc) -> bool {
return loc.filename == null
return not to_bool(loc.filename)
}

export def == (this: SourceLoc, other: SourceLoc) -> bool {
Expand Down

0 comments on commit 655e65b

Please sign in to comment.