diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c91bc2..3d90868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added ### Changed -- Improve how includes with relative paths are resolved during parsing/compilation. +- Improve how includes with relative paths are resolved during parsing/compilation. Relative + include paths are now always relative to the file containing the `include` statement. ### Removed ### Fixed diff --git a/docs/sophia_features.md b/docs/sophia_features.md index e8170c0..3025f82 100644 --- a/docs/sophia_features.md +++ b/docs/sophia_features.md @@ -493,6 +493,24 @@ the file, except that error messages will refer to the original source locations. The language will try to include each file at most one time automatically, so even cyclic includes should be working without any special tinkering. +### Include files using relative paths + +When including code from another file using the `include` statement, the path +is relative to _the file that includes it_. Consider the following file tree: +``` +c1.aes +c3.aes +dir1/c2.aes +dir1/c3.aes +``` + +If `c1.aes` contains `include "c3.aes"` it will include the top level `c3.aes`, +while if `c2.aes` contained the same line it would as expected include +`dir1/c3.aes`. + +Note: Prior to v7.5.0, it would consider the include path relative to _the main +contract file_ (or any explicitly set include path). + ## Standard library Sophia offers [standard library](sophia_stdlib.md) which exposes some