From 617a10aa5f9af68a9e3947a2f530c8de20799dbb Mon Sep 17 00:00:00 2001 From: Daniel McGregor Date: Mon, 4 Nov 2024 10:13:41 +0800 Subject: [PATCH] fix: ensure paths are normalised in Puya source maps --- src/puya/ussemble/debug.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/puya/ussemble/debug.py b/src/puya/ussemble/debug.py index 7859789073..52c34a1854 100644 --- a/src/puya/ussemble/debug.py +++ b/src/puya/ussemble/debug.py @@ -1,4 +1,5 @@ from collections.abc import Mapping, Sequence +from pathlib import Path from puya.models import DebugEvent, DebugInfo from puya.parse import SourceLocation @@ -28,7 +29,7 @@ def build_debug_info( pc - pc_offset: node.source_location for pc, node in pc_ops.items() if pc >= pc_offset } - files = sorted(map(str, {s.file for s in source_map.values() if s and s.file})) + files = sorted(map(_normalize_path, {s.file for s in source_map.values() if s and s.file})) mappings = _get_src_mappings(source_map, files) return DebugInfo( @@ -40,6 +41,10 @@ def build_debug_info( ) +def _normalize_path(path: Path) -> str: + return str(path).replace("\\", "/") + + def _get_src_mappings( source_map: Mapping[int, SourceLocation | None], files: Sequence[str],