diff --git a/src/parse/index.js b/src/parse/index.js index 30b88ae53125..ee0c1d8dfb58 100644 --- a/src/parse/index.js +++ b/src/parse/index.js @@ -123,7 +123,14 @@ export default function parse ( template, options = {} ) { state = state( parser ) || fragment; } - if ( state !== fragment || parser.stack.length > 1 ) { + if ( parser.stack.length > 1 ) { + const current = parser.current(); + + const type = current.type === 'Element' ? `<${current.name}>` : 'Block'; + parser.error( `${type} was left open`, current.start ); + } + + if ( state !== fragment ) { parser.error( 'Unexpected end of input' ); } diff --git a/test/parse.js b/test/parse.js index caa132bbdf65..68e3d18664d8 100644 --- a/test/parse.js +++ b/test/parse.js @@ -45,7 +45,7 @@ describe( 'parse', () => { svelte.compile( `
foo
\ No newline at end of file diff --git a/test/parser/error-unexpected-end-of-input/error.json b/test/parser/error-unexpected-end-of-input/error.json index e171d2a2e812..87ecce83bc2e 100644 --- a/test/parser/error-unexpected-end-of-input/error.json +++ b/test/parser/error-unexpected-end-of-input/error.json @@ -1,8 +1,8 @@ { - "message": "Unexpected end of input", + "message": "