Skip to content

Commit

Permalink
Merge f764499 into 0e56728
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcnn authored Jun 3, 2024
2 parents 0e56728 + f764499 commit f1ddf14
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 4 deletions.
10 changes: 8 additions & 2 deletions sway-core/src/semantic_analysis/ast_node/declaration/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ impl ty::TyStructDecl {
new_fields.push(ty::TyStructField::type_check(handler, ctx.by_ref(), field)?);
}

let mut path: CallPath = name.into();
path = path.to_fullpath(ctx.engines(), ctx.namespace());
let mut path: CallPath = name.clone().into();
if let Some(ref pkg_name) = ctx.namespace().root_module().name {
path.prefixes.push(pkg_name.clone());
};
for mod_path in ctx.namespace().mod_path() {
path.prefixes.push(mod_path.clone())
};
path.is_absolute = true;

// create the struct decl
let decl = ty::TyStructDecl {
Expand Down
3 changes: 2 additions & 1 deletion sway-core/src/semantic_analysis/namespace/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl Namespace {
module_span: Span,
) -> SubmoduleNamespace {
let init = self.init.clone();
let is_external = self.module(engines).is_external;
self.module_mut(engines)
.submodules
.entry(mod_name.to_string())
Expand All @@ -284,7 +285,7 @@ impl Namespace {
new_module.name = Some(mod_name);
new_module.span = Some(module_span);
new_module.visibility = visibility;
new_module.is_external = false;
new_module.is_external = is_external;
new_module.mod_path = submod_path;
SubmoduleNamespace {
namespace: self,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
license = "Apache-2.0"
name = "callpath_local_shadowing"
entry = "main.sw"
implicit-std = false

[dependencies]
std = { path = "../../../../../../../sway-lib-std" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"configurables": [],
"encoding": "1",
"functions": [
{
"attributes": null,
"inputs": [],
"name": "main",
"output": {
"name": "",
"type": 0,
"typeArguments": null
}
}
],
"loggedTypes": [],
"messagesTypes": [],
"types": [
{
"components": [],
"type": "()",
"typeId": 0,
"typeParameters": null
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"configurables": [],
"encoding": "1",
"functions": [
{
"attributes": null,
"inputs": [],
"name": "main",
"output": {
"name": "",
"type": 0,
"typeArguments": null
}
}
],
"loggedTypes": [],
"messagesTypes": [],
"types": [
{
"components": [],
"type": "()",
"typeId": 0,
"typeParameters": null
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library;

pub struct TestStruct {
pub a: u64,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
script;

mod lib;

use lib::*;

struct TestStruct {
pub x: u64,
pub y: u64,
}

fn main() {
let ts = TestStruct { x: 0, y: 0 };
poke(ts.x);
}

fn poke<T>(_x: T) { }
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
category = "disabled"
category = "compile"
expected_warnings = 27

0 comments on commit f1ddf14

Please sign in to comment.