Skip to content

Commit bc8c66c

Browse files
authored
Add hotfix to deal with duplicate fields in teal (#52)
add hotfix to deal with duplicate fields in teal
1 parent 833e90e commit bc8c66c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

languages/bevy_mod_scripting_lua/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ path="src/lib.rs"
4242
[dependencies]
4343
bevy= { version = "0.10.1", default-features = false}
4444
bevy_mod_scripting_core = {path="../../bevy_mod_scripting_core", version = "0.2.2" }
45-
tealr = { version = "=0.9.0-alpha4", git = "https://github.com/awestlake87/tealr", rev = "120ab2da424fbfaaf1a96f77c60072707399a4ba", features=["mlua_vendored","mlua_send"]}
45+
tealr = { version = "=0.9.0-alpha4", features=["mlua_vendored","mlua_send"]}
4646
parking_lot = "0.12.1"
4747
serde_json = "1.0.81"
4848
serde = { version = "1", features = ["derive"] }

languages/bevy_mod_scripting_lua/src/docs.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77

88
use bevy::asset::FileAssetIo;
9-
use tealr::TypeWalker;
9+
use tealr::{TypeGenerator, TypeWalker};
1010

1111
use bevy_mod_scripting_core::prelude::*;
1212

@@ -86,11 +86,18 @@ impl DocFragment for LuaDocFragment {
8686
let docs_name = self.name().to_owned();
8787

8888
// build the type walker
89-
let tw = self
89+
let mut tw = self
9090
.walker
9191
.into_iter()
9292
.fold(TypeWalker::new(), |a, v| (v.builder)(a));
9393

94+
// fixes bug in tealr which causes syntax errors in teal due to duplicate fields (from having both getters and setters)
95+
tw.given_types.iter_mut().for_each(|tg| {
96+
if let TypeGenerator::Record(rg) = tg {
97+
rg.fields.dedup_by(|a, b| a.name == b.name);
98+
}
99+
});
100+
94101
// generate json file
95102
let json = serde_json::to_string_pretty(&tw)
96103
.map_err(|e| ScriptError::DocGenError(e.to_string()))?;

0 commit comments

Comments
 (0)