Compare commits

...

2 Commits

Author SHA1 Message Date
Laurenz
e4f8e57c53
Fix unnecessary import rename warning (#5828) 2025-02-06 21:10:43 +00:00
Laurenz
a1c73b41b8
Document removals in changelog (#5827) 2025-02-06 20:57:46 +00:00
3 changed files with 22 additions and 9 deletions

View File

@ -44,11 +44,10 @@ impl Eval for ast::ModuleImport<'_> {
} }
// If there is a rename, import the source itself under that name. // If there is a rename, import the source itself under that name.
let bare_name = self.bare_name();
let new_name = self.new_name(); let new_name = self.new_name();
if let Some(new_name) = new_name { if let Some(new_name) = new_name {
if let Ok(source_name) = &bare_name { if let ast::Expr::Ident(ident) = self.source() {
if source_name == new_name.as_str() { if ident.as_str() == new_name.as_str() {
// Warn on `import x as x` // Warn on `import x as x`
vm.engine.sink.warn(warning!( vm.engine.sink.warn(warning!(
new_name.span(), new_name.span(),
@ -57,6 +56,7 @@ impl Eval for ast::ModuleImport<'_> {
} }
} }
// Define renamed module on the scope.
vm.define(new_name, source.clone()); vm.define(new_name, source.clone());
} }

View File

@ -45,6 +45,7 @@ description: Changes slated to appear in Typst 0.13.0
result in a warning result in a warning
- The default show rules of various built-in elements like lists, quotes, etc. - The default show rules of various built-in elements like lists, quotes, etc.
were adjusted to ensure they produce/don't produce paragraphs as appropriate were adjusted to ensure they produce/don't produce paragraphs as appropriate
- Removed support for booleans and content in [`outline.indent`]
- The [`outline`] function was fully reworked to improve its out-of-the-box - The [`outline`] function was fully reworked to improve its out-of-the-box
behavior **(Breaking change)** behavior **(Breaking change)**
- [Outline entries]($outline.entry) are now [blocks]($block) and are thus - [Outline entries]($outline.entry) are now [blocks]($block) and are thus
@ -312,8 +313,20 @@ feature flag.
functions directly accepting both paths and bytes functions directly accepting both paths and bytes
- The `sect` and its variants in favor of `inter`, and `integral.sect` in favor - The `sect` and its variants in favor of `inter`, and `integral.sect` in favor
of `integral.inter` of `integral.inter`
- Fully removed type/str compatibility behavior (e.g. `{int == "integer"}`)
which was temporarily introduced in Typst 0.8 **(Breaking change)** ## Removals
- Removed `style` function and `styles` argument of [`measure`], use a [context]
expression instead **(Breaking change)**
- Removed `state.display` function, use [`state.get`] instead
**(Breaking change)**
- Removed `location` argument of [`state.at`], [`counter.at`], and [`query`]
**(Breaking change)**
- Removed compatibility behavior where [`counter.display`] worked without
[context] **(Breaking change)**
- Removed compatibility behavior of [`locate`] **(Breaking change)**
- Removed compatibility behavior of type/str comparisons
(e.g. `{int == "integer"}`) which was temporarily introduced in Typst 0.8
**(Breaking change)**
## Development ## Development
- The `typst::compile` function is now generic and can return either a - The `typst::compile` function is now generic and can return either a

View File

@ -255,6 +255,10 @@
// Warning: 17-21 unnecessary import rename to same name // Warning: 17-21 unnecessary import rename to same name
#import enum as enum #import enum as enum
--- import-rename-necessary ---
#import "module.typ" as module: a
#test(module.a, a)
--- import-rename-unnecessary-mixed --- --- import-rename-unnecessary-mixed ---
// Warning: 17-21 unnecessary import rename to same name // Warning: 17-21 unnecessary import rename to same name
#import enum as enum: item #import enum as enum: item
@ -263,10 +267,6 @@
// Warning: 31-35 unnecessary import rename to same name // Warning: 31-35 unnecessary import rename to same name
#import enum as enum: item as item #import enum as enum: item as item
--- import-item-rename-unnecessary-string ---
// Warning: 25-31 unnecessary import rename to same name
#import "module.typ" as module
--- import-item-rename-unnecessary-but-ok --- --- import-item-rename-unnecessary-but-ok ---
#import "modul" + "e.typ" as module #import "modul" + "e.typ" as module
#test(module.b, 1) #test(module.b, 1)