@tishlang/tish-lint 3.14.0 → 3.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/tish-lint CHANGED
Binary file
@@ -1090,6 +1090,16 @@ fn build_file(
1090
1090
  } else {
1091
1091
  tishlang_native::NativeBuildConfig::desktop()
1092
1092
  };
1093
+ // Release builds name the triple so the binary targets the platform baseline instead of the
1094
+ // build machine's CPU, and so one host can build each slice of a universal binary.
1095
+ let mut build_config = build_config;
1096
+ if build_config.cargo_target.is_none() {
1097
+ if let Ok(triple) = std::env::var("TISH_NATIVE_CARGO_TARGET") {
1098
+ if !triple.is_empty() {
1099
+ build_config.cargo_target = Some(triple);
1100
+ }
1101
+ }
1102
+ }
1093
1103
 
1094
1104
  if is_js {
1095
1105
  let source = fs::read_to_string(&input_path).map_err(|e| format!("{}", e))?;
@@ -3086,8 +3086,9 @@ impl<'a> Compiler<'a> {
3086
3086
  props: &[JsxProp],
3087
3087
  children: &[JsxChild],
3088
3088
  ) -> Result<(), CompileError> {
3089
- let h_idx = self.name_idx(&Arc::from("h"));
3090
- self.emit_u16(Opcode::LoadGlobal, h_idx);
3089
+ // `h`, `Fragment` and component tags resolve lexically (imports, module `fn`s, locals)
3090
+ // and fall back to globals, so embedder-injected `h` via `set_global` still works.
3091
+ self.emit_var_load(&Arc::from("h"));
3091
3092
  let tag_str = tag.as_ref();
3092
3093
  let is_component = tag_str
3093
3094
  .chars()
@@ -3095,8 +3096,7 @@ impl<'a> Compiler<'a> {
3095
3096
  .map(|c| c.is_uppercase())
3096
3097
  .unwrap_or(false);
3097
3098
  if is_component {
3098
- let tag_idx = self.name_idx(tag);
3099
- self.emit_u16(Opcode::LoadGlobal, tag_idx);
3099
+ self.emit_var_load(tag);
3100
3100
  } else {
3101
3101
  let tag_const = self.constant_idx(Constant::String(Arc::from(tag_str)));
3102
3102
  self.emit(Opcode::LoadConst);
@@ -3109,10 +3109,8 @@ impl<'a> Compiler<'a> {
3109
3109
  }
3110
3110
 
3111
3111
  fn compile_jsx_fragment(&mut self, children: &[JsxChild]) -> Result<(), CompileError> {
3112
- let h_idx = self.name_idx(&Arc::from("h"));
3113
- self.emit_u16(Opcode::LoadGlobal, h_idx);
3114
- let fragment_idx = self.name_idx(&Arc::from("Fragment"));
3115
- self.emit_u16(Opcode::LoadGlobal, fragment_idx);
3112
+ self.emit_var_load(&Arc::from("h"));
3113
+ self.emit_var_load(&Arc::from("Fragment"));
3116
3114
  let null_idx = self.constant_idx(Constant::Null);
3117
3115
  self.emit(Opcode::LoadConst);
3118
3116
  self.chunk.write_u16(null_idx);
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "tishlang_lint"
3
- version = "3.14.0"
3
+ version = "3.15.1"
4
4
  edition = "2021"
5
5
  description = "AST-based linter for Tish"
6
6
  license-file = { workspace = true }
@@ -225,12 +225,16 @@ pub fn build_via_cargo_with_config(
225
225
  };
226
226
 
227
227
  // mimalloc as the program's global allocator — binary output only (a staticlib does not own the
228
- // allocator), native only (don't cross-compile mimalloc's C). Adds one cached dep + a global_alloc
228
+ // allocator), native or another macOS slice only (the host clang builds mimalloc's C for both
229
+ // Mac architectures; other cross targets are skipped). Adds one cached dep + a global_alloc
229
230
  // statement; semantically transparent. `TISH_NATIVE_FAST_ALLOC=0` opts out.
230
231
  let use_fast_alloc = fast_alloc_enabled()
231
232
  && build_config.artifact != NativeArtifact::StaticLib
232
233
  && build_config.artifact != NativeArtifact::FfiModule
233
- && build_config.cargo_target.is_none();
234
+ && build_config
235
+ .cargo_target
236
+ .as_deref()
237
+ .map_or(true, |t| cfg!(target_os = "macos") && t.ends_with("-apple-darwin"));
234
238
  if build_config.artifact == NativeArtifact::FfiModule {
235
239
  let guest_path = Path::new(&runtime_path)
236
240
  .parent()
@@ -107,7 +107,12 @@ pub fn compile_to_native_with_config(
107
107
  ios_runtime_features(f)
108
108
  }
109
109
  };
110
- let cross_cap = build_config.cargo_target.as_ref().map(|_| {
110
+ // A desktop triple (one slice of a universal macOS build) is not a restricted target.
111
+ let capped = build_config
112
+ .cargo_target
113
+ .as_deref()
114
+ .filter(|t| is_gba || !t.ends_with("-apple-darwin"));
115
+ let cross_cap = capped.map(|_| {
111
116
  cap(features)
112
117
  .into_iter()
113
118
  .collect::<std::collections::HashSet<_>>()
@@ -130,7 +135,7 @@ pub fn compile_to_native_with_config(
130
135
  message: e.to_string(),
131
136
  })?;
132
137
 
133
- let features_for_cargo = if build_config.cargo_target.is_some() {
138
+ let features_for_cargo = if capped.is_some() {
134
139
  cap(&effective_features)
135
140
  } else {
136
141
  effective_features
@@ -0,0 +1,42 @@
1
+ //! Bytecode JSX resolves `h`, `Fragment` and component tags lexically, falling back to globals.
2
+
3
+ use tishlang_bytecode::compile;
4
+ use tishlang_vm::run;
5
+
6
+ fn run_src(src: &str) {
7
+ let program = tishlang_parser::parse(src).expect("parse");
8
+ let chunk = compile(&program).expect("compile");
9
+ run(&chunk).expect("run");
10
+ }
11
+
12
+ #[test]
13
+ fn component_tag_resolves_script_level_fn() {
14
+ run_src(
15
+ r#"
16
+ fn h(tag, props, children) {
17
+ if (typeof tag === "function") { return tag(props) }
18
+ return { tag: tag, props: props, children: children }
19
+ }
20
+ fn Row(props) { return <item title={props.title} /> }
21
+ let tree = <list><Row title="a" /></list>
22
+ let row = tree.children[0]
23
+ if (row.tag !== "item" || row.props.title !== "a") { throw "component tag did not resolve" }
24
+ "#,
25
+ );
26
+ }
27
+
28
+ #[test]
29
+ fn h_and_fragment_resolve_from_enclosing_scope() {
30
+ run_src(
31
+ r#"
32
+ fn render() {
33
+ let Fragment = "frag"
34
+ let h = (tag, props, children) => typeof tag === "function" ? tag(props) : { tag: tag, children: children }
35
+ fn Inner(p) { return <leaf /> }
36
+ return <><Inner /></>
37
+ }
38
+ let t = render()
39
+ if (t.tag !== "frag" || t.children[0].tag !== "leaf") { throw "local h/Fragment/component not used" }
40
+ "#,
41
+ );
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tishlang/tish-lint",
3
- "version": "3.14.0",
3
+ "version": "3.15.1",
4
4
  "description": "Tish code linter",
5
5
  "license": "PIF",
6
6
  "repository": {
Binary file
Binary file
Binary file
Binary file
Binary file